Add speculation rules prefetch #11426
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is an incomplete draft. Progress tracker for what I would consider an acceptable MVP:
specfmt
to rewrap everything to 100 charactersThis omits actually defining the prefetch operation. I think it would be reasonable to have HTML refer to https://wicg.github.io/nav-speculation/prefetch.html for that temporarily, and then port over that document in a separate PR or two.
I'm posting this now in case it's helpful to people working on implementations in WebKit and Gecko (/cc @yoavweiss @zcorpan).
This ports the relevant text from https://wicg.github.io/nav-speculation/speculation-rules.html, with minor improvements and additions.
Notable changes from that document:
Allows treating prerender rules as prefetch rules.
Allows the presence of target_hint (a prerender-specific speculation rule key), but ignores it.
Follows the precedent set by import maps a bit more closely in how it integrates with the script processing model. Normatively, it fires error events on the script element for the few things that cause complete parsing failures. (Chromium currently does not do this, but we are willing to.)
Adds conformance requirements for speculation rules JSON documents, following the precedent set by import maps.
Adds explicit callouts for when the implementation may report warnings for parsing failures, following the precedent set by import maps.
Fixes a few minor bugs in the parsing algorithms. E.g., the previous text did not correctly deal with how CSS selector parsing returned a list, or called the slightly wrong algorithm for parsing URL patterns.
Simplified the processing model for the Speculation-Rules HTTP header. The previous text added various concepts around pending fetches and periodic implementation-defined processing of those fetches, all designed to allow the implementation to de-prioritize these fetches in favor of other things that happen during loading. This version instead explicitly allows an implementation-defined wait time and uses a separate task source which user agents can deprioritize.
(See WHATWG Working Mode: Changes for more details.)
/acknowledgements.html ( diff )
/document-lifecycle.html ( diff )
/index.html ( diff )
/indices.html ( diff )
/infrastructure.html ( diff )
/references.html ( diff )
/scripting.html ( diff )
/webappapis.html ( diff )