1. This specification is moving to HTML
The majority of this specification is being upstreamed to the HTML Standard: see whatwg/html#11426 and whatwg/html#11123. The rendered specification text can currently be found at this PR preview.
What remains in this document are some additional patches to support prerendering, which the upstreamed version does not yet cover. Once prefetch is also upstreamed, what remains in this document will likely migrate to [PRERENDERING-REVAMPED].
2. Parsing
Extend the speculation rule set struct with one additional item:
-
prerender rules, a list of speculation rules, initially empty
Extend the speculation rule struct with one additional item:
-
target navigable name hint, a string or null
-
Remove the typesToTreatAsPrefetch construct, and instead parse parsed["
prerender
"] into the prerender rules list, in an identical manner to what is done for parsed["prefetch
"] and the prefetch rules. -
Discard rules parsed from parsed["
prefetch
"] if the target navigable name hint is not null.
Implementations will still be allowed to treat prerender candidates as prefetches, per the modifications in § 3 Processing model.
-
Let targetHint be null.
-
If input["
target_hint
"] exists:-
If input["
target_hint
"] is not a valid navigable target name or keyword:-
The user agent may report a warning to the console indicating that the supplied target hint was invalid.
-
Return null.
-
-
Set targetHint to input["
target_hint
"].
-
and then updating the final step which returns a speculation rule to include setting the target navigable name hint to targetHint.
3. Processing model
A prerender candidate is a speculative load candidate with the following additional item:
-
target navigable name hint, a valid navigable target name or keyword or null
-
Let prerenderCandidates be an empty list.
-
For each ruleSet of document’s speculation rule sets:
-
For each rule of ruleSet’s prerender rules:
-
-
Let referrerPolicy be the result of computing a speculative load referrer policy given rule and null.
-
Append a new prerender candidate with
- URL
-
url
- No-Vary-Search hint
-
rule’s No-Vary-Search hint
- eagerness
-
rule’s eagerness
- referrer policy
-
referrerPolicy
- tags
-
rule’s tags
- target navigable name hint
-
rule’s target navigable name hint
to prerenderCandidates.
-
-
If rule’s predicate is not null, then:
-
Let links be the result of finding matching links given document and rule’s predicate.
-
For each link of links:
-
Let target be rule’s target navigable name hint.
-
If target is null, set it to the result of getting an element’s target given link.
-
Let referrerPolicy be the result of computing a speculative load referrer policy given rule and link.
-
Append a prerender candidate with
- URL
-
link’s url
- No-Vary-Search hint
-
rule’s No-Vary-Search hint
- eagerness
-
rule’s eagerness
- referrer policy
-
referrerPolicy
- tags
-
rule’s tags
- target navigable name hint
-
target
to prerenderCandidates.
-
-
-
-
-
Let speculativeLoadCandidates be the union of prefetchCandidates and prerenderCandidates.
Update subsequent steps for canceling not-still-being-speculated prefetch records to operate on speculativeLoadCandidates instead of prefetchCandidates.
Replace the step which performs the actual prefetching by looping over prefetchCandidates with the following:
-
For each candidate of speculativeLoadCandidates:
-
The user agent may run the following steps:
-
Let tagCandidates be speculativeLoadCandidates.
-
If candidate is a prerender candidate, then set tagCandidates to prerenderCandidates.
-
Let tagsToSend be the result of collecting tags for matching speculative load candidates given candidate and tagCandidates.
-
Let prefetchRecord be a new prefetch record with
- source
-
"
speculation rules
" - URL
-
candidate’s URL
- No-Vary-Search hint
-
candidate’s No-Vary-Search hint
- referrer policy
-
candidate’s referrer policy
- tags
-
tagsToSend
-
If candidate is a prefetch candidate, then set prefetchRecord’s anonymization policy to candidate’s anonymization policy.
-
If candidate is a prerender candidate, then the user agent may run the following steps:
-
Set prefetchRecord’s prerendering traversable to "
to be created
" -
Set prefetchRecord’s prerendering target navigable name hint to candidate’s target navigable name hint.
-
Start a referrer-initiated navigational prerender given document and prefetchRecord.
-
-
If the user agent did not run the previous step, then start a referrer-initiated navigational prefetch given document and prefetchRecord.
-
-