From 2157b330e315fb2adce22964831a3efa9eebc593 Mon Sep 17 00:00:00 2001
From: Noam Rosenthal To process link headers given a To extract links from headers given
+ header list headers: Let links be a new list. Let rawLinkHeaders be the result of getting, decoding, and splitting
` Let attribs be linkObject[" If linkObject[" Append linkObject to
+ links. Return links. To process early hint headers given a
+ response response and an
+ environment reservedEnvironment: Let earlyPolicyContainer be the result of creating a
+ policy container from a fetch response given response and
+ reservedEnvironment. Let links be the result of
+ extracting links from
+ response's header list. Let uncommittedPreloads be an empty list. For each linkObject in links: Let attribs be
+ linkObject[" Let destination be
+ attrib[" Let crossorigin be
+ attrib[" Let destination is not a
+ destination, continue. Let url be the result of parsing
+ linkObject[ Let earlyRequest be the result of
+ creating a potential-CORS request given
+ url, destination, and crossorigin. Set earlyRequest's
+ policy container to
+ earlyPolicyContainer. If attrib[" Let unsafeEndTime be 0. Let earlyResponse be null. Let processResponse given response
+ res be to set earlyResponse to res. Append the following steps given Let potentialRequest be a new
+ request, whose
+ client is document's
+ relevant settings object,
+ URL is earlyRequest's
+ URL,
+ destination is earlyRequest's
+ destination,
+ integrity metadata is
+ request's
+ integrity metadata,
+ mode is earlyRequest's
+ mode, and
+ credentials mode is
+ request's
+ credentials mode. If potentialRequest
+ should be blocked by
+ Content Security Policy, then abort these steps. Let entry be new preload entry whose
+ response. Let verifyAndReport be the following steps given
+ response response: If the result of checking if
+ a
+ response should be blocked be Content Security Policy given
+ potentialRequest and response returns false, then: Report timing for origin given
+ response, document's relevant global object,
+ " If entry's on response
+ available is null, then set entry's
+ response to response; otherwise call
+ entry's
+ on response available given
+ response. Let preloadedResources be document's
+ map of preloaded resources. Let key be the result of
+ creating a preload key given
+ earlyRequest. If preloadedResources[key]
+ exists, then set
+ preloadedResources[key]'s
+ response to response; otherwise,
+ set preloadedResources[key] to a new
+ preload entry whose response is
+ response. If earlyResponse is null, then set processResponse to
+ verifyAndReport; otherwise call verifyAndReport with
+ earlyResponse. Preload request with the following
+ steps given res: set unsafeEndTime to the
+ unsafe shared current time and call processResponse with
+ res. Return uncommittedPreloads. To process link headers given a Let links be the result of
+ extracting links from response's
+ header list. For each linkObject in links: Let attribs be
+ linkObject[" Let expectedPhase be " If expectedPhase is not phase, then
continue. If params includes " If attribs includes " Return true. To preload a resource given a request
+ request and processResponse, which is an algorithm accepting a
+ response:
+ fetch request, with processResponseConsumeBody set to the following steps
+ given response response and null or byte
+ sequence bytesOrNull: If bytesOrNull is a byte sequence, then set response's
+ body to the first return value of safely extracting bytesOrNull. By using processResponseConsumeBody,
+ we have extracted the entire body. This is necessary to ensure the preloader loads
+ the entire body from the network, regardless of whether the preload will be consumed (which
+ is uncertain at this point). This step then resets the request's body to a new body
+ containing the same bytes, so that other specifications can read from it at the time of
+ actual consumption, despite us having already done so once. Otherwise, set response to a network error. Call processResponse with response To create a preload key for a request
+ request, return a new preload key whose URL is request's URL, destination is request's destination, integrity metadata is request's integrity metadata, mode is request's mode, and
+ credentials mode is request's credentials mode. The fetch and process the linked resource steps for this type of linked resource,
given a Let preloadKey be a preload key whose URL is request's URL, destination is request's destination, integrity metadata is request's integrity metadata, mode is request's mode, and
- credentials mode is request's credentials mode. Let preloadKey be the result of
+ creating a preload key given
+ request. Let preloadEntry be a new preload entry.Cross-Origin-Resource-Policy
` headerreport-uri
directiveProcessing `
- Link
` headersDocument
doc, a response response, and a "pre-media
" or "media
" phase:
+
+
+ Link
` from response's HTMLLinkElement : HTMLElement {
target_attributes
"].target_uri
"] does not
+ exist, then continue.
+
+
+
+
+ target_attributes
"].as
"].crossorigin
"] if
+ attrib["crossorigin
"]
+ exists, or the empty string otherwise.target_uri
"] relative to response's
+ URL.integrity
"]
+ exists, then set earlyRequest's
+ integrity metadata to
+ attrib["integrity
"].Document
+ document to uncommittedPreloads:
+
+
+
+
+
+ early-hint
", and unsafeEndTime.Document
doc,
+ a response response, and a
+ "pre-media
" or "media
" phase:
+
-
+
+ target_attributes
"].media
" if either "srcset
", "imagesrcset
", or "HTMLLinkElement : HTMLElement {
media
" and
- params["media
"] does not media
" and
+ attribs["media
"] does not match the environment, then
continue.
+
+
+ link
element el, are:
Fetch request, with processResponseConsumeBody set to the following steps - given response response and null or byte - sequence bytesOrNull:
+Preload request, with the following + steps given response response:
If bytesOrNull is a byte sequence, then set response's - body to the first return value of safely extracting bytesOrNull.
- -By using processResponseConsumeBody, - we have extracted the entire body. This is necessary to ensure the preloader loads - the entire body from the network, regardless of whether the preload will be consumed (which - is uncertain at this point). This step then resets the request's body to a new body - containing the same bytes, so that other specifications can read from it at the time of - actual consumption, despite us having already done so once.
-Otherwise, set response to a network error.
Finalize and report timing with response, given el's
relevant global object and "link
".
Fire an event named load
at el.
Unblock rendering on el.
If preloadEntry's on response available is null, then set preloadEntry's response to response.
Otherwise, call preloadEntry's on response available with response.
Fire an event named load
at el.
Unblock rendering on el.
document
has been createdOnce a navigation params struct is created, this standard does not @@ -88404,9 +88597,10 @@ interface Location { // but see also process response end of body is processResponseEndOfBody, unsafe start time is - unsafeNavigationStartTime, and unsafeNavigationStartTime, has cross-origin redirects is - false.
+ false, and uncommitted preloads is null.Run process a navigate response with navigationType, allowedToDownload, hasTransientActivation, and @@ -88466,9 +88660,10 @@ interface Location { // but see also process response end of body is processResponseEndOfBody, unsafe start time is - unsafeNavigationStartTime, and unsafeNavigationStartTime, has cross-origin redirects is - false.
Run process a navigate response with navigationType,
allowedToDownload, hasTransientActivation, and
@@ -88584,6 +88779,8 @@ interface Location { // but see also Set request's reserved
client to null.
Set uncommittedPreloads to null.
If response is null, fetch request, with + processEarlyHintsResponse set to the following step given a + response earlyResponse: If + uncommittedPreloads is null, then set uncommittedPreloads to the result + of processing early hints headers given + earlyResponse and request's + reserved client.
+Otherwise, perform HTTP-redirect fetch using request and response.
Run process a navigate response with navigationType, allowedToDownload, hasTransientActivation, and @@ -89407,6 +89616,11 @@ interface Location { // but see also issue #2900.
For each commitEarlyPreload in + navigationParams's + uncommitted preloads, + call commitEarlyPreload given document.
+Process link headers given document,
navigationParams's response, and
"pre-media
".
Link
` headersCurrently only preload
links are specified
+ for `Link
` header processing. A dditional link types can be added here in the future.
To extract links from headers given header list headers:
@@ -14323,15 +14327,8 @@ interface HTMLLinkElement : HTMLElement {If linkObject["relation_type
"] is not "preload
", then continue.
Support for additional link types can be added here in the future.
-Let attribs be linkObject["target_attributes
"].
If linkObject["relation_type
"] is not "preload
", then continue.
If linkObject["target_uri
"] does not
exist, then continue.
For each linkObject in links:
+The moment we receive the a early hint link header, we begin
+ fetching earlyRequest. If it comes back before
+ the document
is created, we set earlyResponse to the
+ response of that
+ fetch and once the document
is created we
+ commit it (make it available in the map of preloaded resources as if it was a
+ link
element). If the document
is created first, we commit it as soon
+ as the response becomes available.
Let attribs be
- linkObject["target_attributes
"].
Let attribs be
+ linkObject["target_attributes
"].
Only the "as
", "crossorigin
" and
+ "integrity
" attributes are handled as part of early hint processing.
+ The other ones, in particular "media
",
+ "imagesrcset
", "imagesizes
", and
+ "blocking
" are only applicable once a Document
is
+ created.
If attribs["as
"] does not
+ exist, continue.
Let destination be
- attrib["as
"].
as
"].Let crossorigin be
attrib["crossorigin
"] if
attrib["crossorigin
"]
exists, or the empty string otherwise.
Let destination is not a +
If destination is not a destination, continue.
Let url be the result of parsing
- linkObject[target_uri
"] relative to response's
+ linkObject["target_uri
"] relative to response's
URL.
Let earlyRequest be the result of @@ -14405,54 +14423,25 @@ interface HTMLLinkElement : HTMLElement { document to uncommittedPreloads:
Let potentialRequest be a new - request, whose - client is document's - relevant settings object, - URL is earlyRequest's - URL, - destination is earlyRequest's - destination, - integrity metadata is - request's - integrity metadata, - mode is earlyRequest's - mode, and - credentials mode is - request's - credentials mode.
If potentialRequest - should be blocked by - Content Security Policy, then abort these steps.
Let entry be new preload entry whose response.
Let verifyAndReport be the following steps given +
Let respond be the following steps given response response:
If the result of checking if - a - response should be blocked be Content Security Policy given - potentialRequest and response returns false, then:
- -Report timing for origin given
- response, document's relevant global object,
- "early-hint
", and unsafeEndTime.
If entry's on response - available is null, then set entry's - response to response; otherwise call - entry's - on response available given - response.
Finalize and report timing given
+ response, document's relevant global object,
+ "early-hint
", and unsafeEndTime.
If entry's on response + available is null, then set entry's + response to response; otherwise call + entry's + on response available given + response.
Let preloadedResources be document's map of preloaded resources.
If earlyResponse is null, then set processResponse to - verifyAndReport; otherwise call verifyAndReport with - earlyResponse.
Preload request with the following - steps given res: set unsafeEndTime to the - unsafe shared current time and call processResponse with - res.
Preload earlyRequest with the + following steps given response res: set + unsafeEndTime to the unsafe shared current time and call + processResponse with res.
report-uri
directiveLink
` headersCurrently only preload
links are specified
- for `Link
` header processing. A dditional link types can be added here in the future.
The processing of `Link
` headers apart from preload
, in particular their influence on a Document
's
+ script-blocking style sheet counter, is not defined. See issue #4224 for discussion on integrating
+ this into the spec.
To extract links from headers given header list headers:
@@ -14340,7 +14342,14 @@ interface HTMLLinkElement : HTMLElement { response response and an environment reservedEnvironment: -Early-hint `Link
` headers are always processed
+ before `Link
` headers from the final
+ response, followed by link
elements. This
+ is equivalent to prepending the contents of the early and final
+ `Link
` headers to the Document
's
+ head
element, in respective order.
Let earlyPolicyContainer be the result of creating a policy container from a fetch response given response and reservedEnvironment.
The processing of `Link
` headers apart from preload
, in particular their influence on a Document
's
- script-blocking style sheet counter, is not defined. See issue #4224 for discussion on integrating
- this into the spec.
link
@@ -88857,7 +88860,7 @@ interface Location { // but see also response earlyResponse: If
uncommittedPreloads is null, then set uncommittedPreloads to the result
- of processing early hints headers given
+ of processing early hint headers given
earlyResponse and request's
reserved client.
From d293fca703510df6ce47701dac60c8e22f4f4bc2 Mon Sep 17 00:00:00 2001
From: Noam Rosenthal For each linkObject in links:
-The moment we receive the a early hint link header, we begin +
The moment we receive the early hint link header, we begin
fetching earlyRequest. If it comes back before
the document
is created, we set earlyResponse to the
response of that
From e3473d4b064c51a7b83215fe07a8bded2f89d8d7 Mon Sep 17 00:00:00 2001
From: Noam Rosenthal Link
` headers to the Document
's
head
element, in respective order.
Let earlyPolicyContainer be the result of creating a policy container from a fetch response given response and reservedEnvironment.
Return uncommittedPreloads.
To process link headers given a Document
doc,
@@ -88854,16 +88854,14 @@ interface Location { // but see also fetch request, with
- processEarlyHintsResponse set to the following step given a
- response earlyResponse: If
- uncommittedPreloads is null, then set uncommittedPreloads to the result
- of processing early hint headers given
- earlyResponse and request's
- reserved client.
If response is null, fetch request, with + processEarlyHintsResponse set to the following step given a + response earlyResponse: If + uncommittedPreloads is null, then set uncommittedPreloads to the result + of processing early hint headers given + earlyResponse and request's + reserved client.
Otherwise, perform HTTP-redirect fetch using request and response.
report-uri
directiveEarly-hint `Link
` headers are always processed
before `Link
` headers from the final
- response, followed by link
elements. This
+ response, followed by link
elements. This
is equivalent to prepending the contents of the early and final
`Link
` headers to the Document
's
head
element, in respective order.
document
is created we
commit it (make it available in the map of preloaded resources as if it was a
- link
element). If the document
is created first, we commit it as soon
- as the response becomes available.
+ link
element). If the document
is created first, the
+ response is committed as soon as it becomes
+ available.
Let attribs be
linkObject["target_attributes
"].
Only the "as
", "crossorigin
" and
+
Only the "as
", "crossorigin
", and
"integrity
" attributes are handled as part of early hint processing.
The other ones, in particular "media
",
"imagesrcset
", "imagesizes
", and
@@ -14448,35 +14451,32 @@ interface HTMLLinkElement : HTMLElement {
response.
Let preloadedResources be document's - map of preloaded resources.
Let key be the result of - creating a preload key given - earlyRequest.
Let preloadedResources be document's + map of preloaded resources.
If preloadedResources[key] - exists, then set - preloadedResources[key]'s - response to response; otherwise, - set preloadedResources[key] to a new - preload entry whose response is - response.
Let key be the result of + creating a preload key given + earlyRequest.
If earlyResponse is null, then set processResponse to - respond; otherwise call respond with earlyResponse.
If preloadedResources[key] + exists, then set + preloadedResources[key]'s + response to response; otherwise, + set preloadedResources[key] to a new + preload entry whose response is + response.
If earlyResponse is null, then set processResponse to + respond; otherwise call respond with earlyResponse.
Preload earlyRequest with the following steps given response res: set unsafeEndTime to the unsafe shared current time and call processResponse with res.
Return uncommittedPreloads.
head
element, in respective order.
Let earlyPolicyContainer be the result of creating a - policy container from a fetch response given response and - reservedEnvironment.
Let earlyPolicyContainer be the result of creating a policy container from a + fetch response given response and reservedEnvironment.
+ +This allows the early hint response to + include a Content Security Policy directive which would be + enforced when fetching the early hint + request.
+Let links be the result of extracting links from @@ -88801,7 +88807,13 @@ interface Location { // but see also reserved client to null.
Set uncommittedPreloads to null.
Set uncommittedPreloads to null.
+ +Preloaded links from early hint + headers remain in the preload cache after a same origin redirect, but + get discarded when the redirect is cross-origin.
+Return links.
Early hint headers allow user-agents to perform some operations, such as speculative loading + resources that are likely to be used by the document, before the navigation request is fully + handled by the server and a response code is served. Servers can indicate early hints by serving a + response with a 103 status code before serving the final + response.
+ +Only the first early hint response served during the navigation is handled, and it + is discarded if it is succeeded by a cross-origin redirect. In addition to the early hint, the 103 + response may also contain a Content Security Policy header, which is enforced when + processing the early hints.
+ ++
+To process early hint headers given a response response and an environment reservedEnvironment:
@@ -14357,7 +14374,7 @@ interface HTMLLinkElement : HTMLElement { fetch response given response and reservedEnvironment.This allows the early hint response to - include a Content Security Policy directive which would be + include a Content Security Policy which would be enforced when fetching the early hint request.
@@ -14373,11 +14390,11 @@ interface HTMLLinkElement : HTMLElement {The moment we receive the early hint link header, we begin
fetching earlyRequest. If it comes back before
- the document
is created, we set earlyResponse to the
+ the Document
is created, we set earlyResponse to the
response of that
- fetch and once the document
is created we
- commit it (make it available in the map of preloaded resources as if it was a
- link
element). If the document
is created first, the
+ fetch and once the Document
is created we
+ commit it (by making it available in the map of preloaded resources as if it was a
+ link
element). If the Document
is created first, the
response is committed as soon as it becomes
available.
Let attribs be
linkObject["target_attributes
"].
Only the "as
", "crossorigin
", and
- "integrity
" attributes are handled as part of early hint processing.
- The other ones, in particular "media
",
- "imagesrcset
", "imagesizes
", and
- "blocking
" are only applicable once a Document
is
- created.
Only the as
,
+ crossorigin
, and
+ integrity
attributes are handled as part of early
+ hint processing. The other ones, in particular
+ media
,
+ imagesrcset
,
+ imagesizes
, and "blocking
"
+ are only applicable once a Document
is created.
If attribs["as
"] does not
@@ -14401,8 +14420,8 @@ interface HTMLLinkElement : HTMLElement {
attribs["as
"].
Let crossorigin be
- attrib["crossorigin
"] if
- attrib["crossorigin
"]
+ attribs["crossorigin
"] if
+ attribs["crossorigin
"]
exists, or the empty string otherwise.
If destination is not a @@ -14420,10 +14439,10 @@ interface HTMLLinkElement : HTMLElement { policy container to earlyPolicyContainer.
If attrib["integrity
"]
+
If attribs["integrity
"]
exists, then set earlyRequest's
integrity metadata to
- attrib["integrity
"].
integrity
"].
Let unsafeEndTime be 0.
Otherwise, set response to a network error.
Call processResponse with response
+Call processResponse with response.
To create a preload key for a request
@@ -88868,8 +88887,8 @@ interface Location { // but see also fetch request, with
- processEarlyHintsResponse set to the following step given a
- response earlyResponse: If
+ processEarlyHintsResponse set to the following step
+ given a response earlyResponse: If
uncommittedPreloads is null, then set uncommittedPreloads to the result
of processing early hint headers given
earlyResponse and request's
From ce22dcaf804135c7510f88424bce112e4b02fd3f Mon Sep 17 00:00:00 2001
From: Noam Rosenthal Return links. Early hint headers allow user-agents to perform some operations, such as speculative loading
- resources that are likely to be used by the document, before the navigation request is fully
+ Early hints allow user-agents to perform some operations, such as to speculatively
+ load resources that are likely to be used by the document, before the navigation request is fully
handled by the server and a response code is served. Servers can indicate early hints by serving a
response with a 103 status code before serving the final
response. For example, given the following sequence of responses: the image will start loading before the HTML content arrives. Only the first early hint response served during the navigation is handled, and it
- is discarded if it is succeeded by a cross-origin redirect. In addition to the early hint, the 103
- response may also contain a Content Security Policy header, which is enforced when
- processing the early hints.Early Hint Headers
+ Early Hints
-
+ 103 Early Hint
+ Link: </image.png>; rel=preload; as=image
+
+
+
+ 200 OK
+ Content-Type: text/html
+
+ <!DOCTYPE html>
+ ...
+ <img src="/image.png">
+
+
+
For example, given the following sequence of responses:
++ 103 Early Hint + Content-Security-Policy: style-src: self; + Link: </style.css>; rel=preload; as=style ++ +
+ 103 Early Hint + Link: </image.png>; rel=preload; as=image ++ +
+ 302 Redirect + Location: /alternate.html ++ +
+ 200 OK + Content-Security-Policy: style-src: none; + Link: </font.ttf>; rel=prelad; as=font ++ +
The font and style would be loaded, and the image will be discarded, as only the first early hint + response in the final redirect chain is respected. The late Content Security Policy + header comes after the request to fetch the style has already been performed, but the style will + not be accessible to the document.
+-
To process early hint headers given a
response response and an
@@ -88829,7 +88876,7 @@ interface Location { // but see also Preloaded links from early hint
+ Preloaded links from early hint
headers remain in the preload cache after a same origin redirect, but
get discarded when the redirect is cross-origin.
Return links.
To process link headers given a Document
doc,
+ a response response, and a
+ "pre-media
" or "media
" phase:
Let links be the result of + extracting links from response's + header list.
For each linkObject in links:
+ +Let attribs be
+ linkObject["target_attributes
"].
Let expectedPhase be "media
" if either "srcset
", "imagesrcset
", or "media
" exist in
+ attribs; otherwise false.
If expectedPhase is not phase, then + continue.
If attribs includes "media
" and
+ attribs["media
"] does not match the environment, then
+ continue.
Let element be the result of creating an
+ element given doc, link
, and the HTML
+ namespace.
Set an attribute value for
+ element using "href
" and
+ linkObject["target_uri
"].
Set an attribute value for
+ element using "rel
" and
+ linkObject["relation_type
"].
For each entry in attribs: if
+ entry[0] is "as
", "type
", "crossorigin
", "imagesizes
", "blocking
", "integrity
", "imagesrcset
", or "media
", then set an attribute value for
+ element using entry[0] and entry[1].
Fetch and process + el.
Early hints allow user-agents to perform some operations, such as to speculatively load resources that are likely to be used by the document, before the navigation request is fully @@ -14351,51 +14411,45 @@ interface HTMLLinkElement : HTMLElement {
For example, given the following sequence of responses:
-- 103 Early Hint - Link: </image.png>; rel=preload; as=image -+
103 Early Hint +Link: </image.png>; rel=preload; as=image-
- 200 OK - Content-Type: text/html +200 OK +Content-Type: text/html - <!DOCTYPE html> - ... - <img src="/image.png"> -+<!DOCTYPE html> +... +<img src="/image.png">
the image will start loading before the HTML content arrives.
Only the first early hint response served during the navigation is handled, and it - is discarded if it is succeeded by a cross-origin redirect. In addition to the early hint, it is - possbile that the 103 response contains a Content Security Policy header, which is - enforced when processing the early hints.
+ is discarded if it is succeeded by a cross-origin redirect. + +In addition to the `Link
` headers, it is possible that the 103
+ response contains a Content Security Policy header, which is enforced when processing
+ the early hint.
For example, given the following sequence of responses:
-- 103 Early Hint - Content-Security-Policy: style-src: self; - Link: </style.css>; rel=preload; as=style -- -
- 103 Early Hint - Link: </image.png>; rel=preload; as=image -- -
- 302 Redirect - Location: /alternate.html -- -
- 200 OK - Content-Security-Policy: style-src: none; - Link: </font.ttf>; rel=prelad; as=font -+
103 Early Hint +Content-Security-Policy: style-src: self; +Link: </style.css>; rel=preload; as=style+ +
103 Early Hint +Link: </image.png>; rel=preload; as=image+ +
302 Redirect +Location: /alternate.html+ +
200 OK +Content-Security-Policy: style-src: none; +Link: </font.ttf>; rel=preload; as=font
The font and style would be loaded, and the image will be discarded, as only the first early hint response in the final redirect chain is respected. The late Content Security Policy @@ -14553,66 +14607,6 @@ interface HTMLLinkElement : HTMLElement {
Return uncommittedPreloads.
To process link headers given a Document
doc,
- a response response, and a
- "pre-media
" or "media
" phase:
Let links be the result of - extracting links from response's - header list.
For each linkObject in links:
- -Let attribs be
- linkObject["target_attributes
"].
Let expectedPhase be "media
" if either "srcset
", "imagesrcset
", or "media
" exist in
- attribs; otherwise false.
If expectedPhase is not phase, then - continue.
If attribs includes "media
" and
- attribs["media
"] does not match the environment, then
- continue.
Let element be the result of creating an
- element given doc, link
, and the HTML
- namespace.
Set an attribute value for
- element using "href
" and
- linkObject["target_uri
"].
Set an attribute value for
- element using "rel
" and
- linkObject["relation_type
"].
For each entry in attribs: if
- entry[0] is "as
", "type
", "crossorigin
", "imagesizes
", "blocking
", "integrity
", "imagesrcset
", or "media
", then set an attribute value for
- element using entry[0] and entry[1].
Fetch and process - el.
link
From 48cb73bbe0e5e4c8e3dfb67b902ff0011555409e Mon Sep 17 00:00:00 2001
From: Domenic Denicola imagesrcset
", or "media
" exist in
- attribs; otherwise false.
+ attribs; otherwise "pre-media
".
If expectedPhase is not phase, then continue.
If attribs includes "media
" and
- attribs["media
"] does not match the environment, then
+
If attribs["media
"] exists and attribs["media
"]
+ does not match the environment, then
continue.
Let element be the result of creating an @@ -14401,7 +14401,7 @@ interface HTMLLinkElement : HTMLElement {
Early hints allow user-agents to perform some operations, such as to speculatively load resources that are likely to be used by the document, before the navigation request is fully @@ -14451,99 +14451,96 @@ Content-Security-Policy: style-src: none; Link: </font.ttf>; rel=preload; as=font -
The font and style would be loaded, and the image will be discarded, as only the first early hint - response in the final redirect chain is respected. The late Content Security Policy - header comes after the request to fetch the style has already been performed, but the style will - not be accessible to the document.
+The font and style would be loaded, and the image will be discarded, as only the first early + hint response in the final redirect chain is respected. The late Content Security + Policy header comes after the request to fetch the style has already been performed, but + the style will not be accessible to the document.
-To process early hint headers given a - response response and an - environment reservedEnvironment:
+To process early hint headers given a response response and an environment + reservedEnvironment:
Early-hint `Link
` headers are always processed
- before `Link
` headers from the final
- response, followed by link
elements. This
- is equivalent to prepending the contents of the early and final
- `Link
` headers to the Document
's
- head
element, in respective order.
Link
` headers from the final response, followed by link
elements. This is
+ equivalent to prepending the contents of the early and final `Link
` headers to the Document
's head
element,
+ in respective order.
Let earlyPolicyContainer be the result of creating a policy container from a - fetch response given response and reservedEnvironment.
+Let earlyPolicyContainer be the result of creating a policy container from + a fetch response given response and reservedEnvironment.
This allows the early hint response to - include a Content Security Policy which would be - enforced when fetching the early hint - request.
+ include a Content Security Policy which would be enforced when fetching the early hint request.Let links be the result of - extracting links from - response's header list.
Let links be the result of extracting links from response's header list.
Let uncommittedPreloads be an empty list.
For each linkObject in links:
-The moment we receive the early hint link header, we begin
- fetching earlyRequest. If it comes back before
- the Document
is created, we set earlyResponse to the
- response of that
- fetch and once the Document
is created we
- commit it (by making it available in the map of preloaded resources as if it was a
- link
element). If the Document
is created first, the
- response is committed as soon as it becomes
- available.
The moment we receive the early hint link header, we begin fetching earlyRequest. If it comes back before the
+ Document
is created, we set earlyResponse to the response of that fetch and
+ once the Document
is created we commit it (by making it available in the map
+ of preloaded resources as if it was a link
element). If the
+ Document
is created first, the response is
+ committed as soon as it becomes available.
Let attribs be
- linkObject["target_attributes
"].
Only the as
,
- crossorigin
, and
- integrity
attributes are handled as part of early
- hint processing. The other ones, in particular
- media
,
- imagesrcset
,
- imagesizes
, and "blocking
"
- are only applicable once a Document
is created.
Let attribs be linkObject["target_attributes
"].
Only the as
, crossorigin
, and integrity
attributes are handled as part of early hint
+ processing. The other ones, in particular media
, imagesrcset
, imagesizes
, and "blocking
" are
+ only applicable once a Document
is created.
If attribs["as
"] does not
- exist, continue.
If attribs["as
"] does not exist, then continue.
Let destination be
- attribs["as
"].
Let destination be attribs["as
"].
Let crossorigin be
- attribs["crossorigin
"] if
- attribs["crossorigin
"]
- exists, or the empty string otherwise.
Let crossorigin be attribs["crossorigin
"] if attribs["crossorigin
"] exists,
+ or the empty string otherwise.
If destination is not a - destination, continue.
If destination is not a destination, continue.
Let url be the result of parsing
linkObject["target_uri
"] relative to response's
URL.
Let earlyRequest be the result of - creating a potential-CORS request given - url, destination, and crossorigin.
Let earlyRequest be the result of creating a potential-CORS request given url, + destination, and crossorigin.
Set earlyRequest's - policy container to - earlyPolicyContainer.
Set earlyRequest's policy + container to earlyPolicyContainer.
If attribs["integrity
"]
- exists, then set earlyRequest's
- integrity metadata to
- attribs["integrity
"].
If attribs["integrity
"] exists, then set earlyRequest's integrity metadata to
+ attribs["integrity
"].
Let unsafeEndTime be 0.
Let entry be new preload entry whose - response.
Let entry be new preload entry whose response.
Let respond be the following steps given - response response:
+Let respond be the following steps given response response:
Finalize and report timing given
- response, document's relevant global object,
- "early-hint
", and unsafeEndTime.
Finalize and report timing given response,
+ document's relevant global object, "early-hint
", and unsafeEndTime.
If entry's on response - available is null, then set entry's - response to response; otherwise call - entry's - on response available given + available is null, then set entry's response to response; otherwise call entry's on response available given response.
Let preloadedResources be document's - map of preloaded resources.
Let preloadedResources be document's map of preloaded + resources.
Let key be the result of - creating a preload key given - earlyRequest.
Let key be the result of creating a + preload key given earlyRequest.
If preloadedResources[key] - exists, then set - preloadedResources[key]'s - response to response; otherwise, - set preloadedResources[key] to a new +
If preloadedResources[key] exists, then set preloadedResources[key]'s response to response; otherwise, set preloadedResources[key] to a new preload entry whose response is response.
To preload a resource given a request - request and processResponse, which is an algorithm accepting a - response: - fetch request, with processResponseConsumeBody set to the following steps - given response response and null or byte - sequence bytesOrNull:
+ request and processResponse, which is an algorithm accepting a response: fetch + request, with processResponseConsumeBody + set to the following steps given response + response and null or byte sequence bytesOrNull:By using processResponseConsumeBody, we have extracted the entire body. This is necessary to ensure the preloader loads - the entire body from the network, regardless of whether the preload will be consumed (which - is uncertain at this point). This step then resets the request's body to a new body - containing the same bytes, so that other specifications can read from it at the time of - actual consumption, despite us having already done so once.
+ data-x="concept-response-body">body. This is necessary to ensure the preloader loads the + entire body from the network, regardless of whether the preload will be consumed (which is + uncertain at this point). This step then resets the request's body to a new body containing the + same bytes, so that other specifications can read from it at the time of actual consumption, + despite us having already done so once.Otherwise, set response to a network error.
Let preloadKey be the result of - creating a preload key given - request.
Let preloadKey be the result of creating a + preload key given request.
Let preloadEntry be a new preload entry.
Otherwise, call preloadEntry's on response available with response.
Fire an event named load
at el.
Process link headers given document,
navigationParams's response, and
From 7657f5c4737585c525c3d00749477a3f574326a1 Mon Sep 17 00:00:00 2001
From: Domenic Denicola
Let preloadedResources be document's map of preloaded resources.