-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit c6314c8
authored
Add speculation rules prefetch
This ports the relevant text from https://github.com/WICG/nav-speculation/blob/90ccea636881ab7c9b4aabd04bfa233ef33477ee/speculation-rules.bs, with minor improvements and additions. It does *not* port the actual navigational prefetching algorithms, which are left in https://wicg.github.io/nav-speculation/prefetch.html for now. Similarly, the prerendering parts have been moved to https://wicg.github.io/nav-speculation/prerendering.html#speculation-rules.
Part of #11123.
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 global object for the few things that cause complete parsing failures. (Chromium recently changed to do this.)
* 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, uses a separate task source which user agents can deprioritize, and explicitly excludes non-top-level-traversables from caring about the header.
* Be explicit about when to consider speculative loads, instead of using vague language about "whenever something relevant changes".
* Give an explicit algorithm for how speculative load candidates are grouped and redundant ones coalesced, instead of stating that it must be done somehow.
* Add re-parsing of `<script type=speculationrules>` on base URL changes, to match the Chromium implementation.
* Remove the re-parsing of `<script type=speculationrules>` on text content changes, to match the Chromium implementation and also match `<script type=importmap>`.
* Slightly shorten some of the security and privacy considerations, e.g., by not mentioning mixed content concerns.1 parent 66b4fb9 commit c6314c8Copy full SHA for c6314c8
Expand file treeCollapse file tree
1 file changed
+2413
-39
lines changed
0 commit comments