Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define link processing for prefetch #8111

Merged
merged 10 commits into from
Jan 17, 2023
53 changes: 48 additions & 5 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -26048,15 +26048,58 @@ document.body.appendChild(wbr);</code></pre>
link</span>. This keyword is <span>body-ok</span>.</p>

<p>The <code data-x="rel-prefetch">prefetch</code> keyword indicates that preemptively <span
data-x="concept-fetch">fetching</span> and caching the specified resource is likely to be
beneficial, as it is highly likely that the user will require this resource for future
navigations. <span w-nodev>User agents must implement the processing model of the <code
data-x="rel-prefetch">prefetch</code> keyword described in <cite>Resource Hints</cite>.</span>
<ref spec=RESOURCEHINTS></p>
data-x="concept-fetch">fetching</span> and caching the specified resource or same-site document is
likely to be beneficial, as it is highly likely that the user will require this resource for
future navigations.</p>

<p>There is no default type for resources given by the <code data-x="rel-prefetch">prefetch</code>
keyword.</p>

<p>The <span>fetch and process the linked resource</span> algorithm for <code
data-x="rel-prefetch">prefetch</code> links, given a <code>link</code> element
<var>el</var>, is as follows:</p>

<ol>
<li><p>If <var>el</var>'s <code data-x="attr-link-href">href</code> attribute's value is the
empty string, then return.</p></li>

<li><p>Let <var>options</var> be the result of <span data-x="create link options from
element">creating link options</span> from <var>el</var>.</p></li>

<li><p>Set <var>options</var>'s <span data-x="link options destination">destination</span> to
the empty string.</p></li>

<li><p>Let <var>request</var> be the result of <span data-x="create a link request">creating a
link request</span> given <var>options</var>.</p></li>

<li><p>If <var>request</var> is null, then return.</p></li>

<li><p>Set <var>request</var>'s <span data-x="concept-request-initiator">initiator</span> to
"<code data-x="">prefetch</code>".</p></li>

<li>
<p>Let <var>processPrefetchResponse</var> be the following steps given a <span
data-x="concept-response">response</span> <var>response</var> and null, failure, or a
<span>byte sequence</span> <var>bytesOrNull</var>:</p>

<ol>
<li><p>If <var>response</var> is a <span>network error</span>, <span
data-x="concept-event-fire">fire an event</span> named <code
data-x="event-error">error</code> at <var>el</var>.</p></li>

<li><p>Otherwise, <span data-x="concept-event-fire">fire an event</span> named <code
data-x="event-load">load</code> at <var>el</var>.</p></li>
</ol>
</li>

<li><p>The user agent should <span data-x="concept-fetch">fetch</span> <var>request</var>, with
<i data-x="processResponseConsumeBody">processResponseConsumeBody</i> set to
<var>processPrefetchResponse</var>. User agents may delay the fetching of <var>request</var> to
prioritize other requests that are necessary for the current document.</p></li>
</ol>

<p>The <span>process a link header</span> steps for this type of linked resource are to do
nothing.</p>

<h5>Link type "<dfn for="link/rel" attr-value><code
data-x="rel-preload">preload</code></dfn>"</h5>
Expand Down