Skip to content

Commit 762589c

Browse files
Allow as=style and as=json for <link rel=modulepreload>
Updates the definition of rel=modulepreload to support as=style and as=json for preloading style and JSON module scripts respectively. Also clarify the allowed values for rel=preload with a new "preload destination" concept. Fixes #10233.
1 parent d460cff commit 762589c

File tree

1 file changed

+33
-28
lines changed

1 file changed

+33
-28
lines changed

source

Lines changed: 33 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -16397,17 +16397,19 @@ interface <dfn interface>HTMLLinkElement</dfn> : <span>HTMLElement</span> {
1639716397
<hr>
1639816398

1639916399
<p>The <dfn element-attr for="link"><code data-x="attr-link-as">as</code></dfn> attribute
16400-
specifies the <span data-x="concept-potential-destination">potential destination</span> for a
16401-
preload request for the resource given by the <code data-x="attr-link-href">href</code> attribute.
16402-
It is an <span>enumerated attribute</span>. Each <span
16403-
data-x="concept-potential-destination">potential destination</span> is a keyword for this
16400+
specifies either a <span>preload destination</span> or a <span>module preload destination</span>
16401+
for a preload request for the resource given by the <code data-x="attr-link-href">href</code>
16402+
attribute. It is an <span>enumerated attribute</span>. Each of the union of <span
16403+
data-x="preload destination">preload destinations</span> and <span
16404+
data-x="module preload destination">module preload destinations</span> is a keyword for this
1640416405
attribute, mapping to a state of the same name. The attribute must be specified on
1640516406
<code>link</code> elements that have a <code data-x="attr-link-rel">rel</code> attribute that
16406-
contains the <code data-x="rel-preload">preload</code> keyword. It may be specified on
16407-
<code>link</code> elements that have a <code data-x="attr-link-rel">rel</code> attribute that
16408-
contains the <code data-x="rel-modulepreload">modulepreload</code> keyword; in such cases it must
16409-
have a value which is a <span data-x="concept-script-like-destination">script-like
16410-
destination</span>. For other <code>link</code> elements, it must not be specified.</p>
16407+
contains the <code data-x="rel-preload">preload</code> keyword; in such cases it must have a
16408+
value which is a <span>preload destination</span>. It may be specified on <code>link</code>
16409+
elements that have a <code data-x="attr-link-rel">rel</code> attribute that contains the
16410+
<code data-x="rel-modulepreload">modulepreload</code> keyword; in such cases it must have a value
16411+
which is a <span>module preload destination</span>. For other <code>link</code> elements, it must
16412+
not be specified.</p>
1641116413

1641216414
<p w-nodev>The processing model for how the <code data-x="attr-link-as">as</code> attribute is
1641316415
used is given in an individual link type's <span>fetch and process the linked resource</span>
@@ -27474,7 +27476,7 @@ document.body.appendChild(wbr);</code></pre>
2747427476
<td colspan="2"><em>not allowed</em></td>
2747527477
<td class="yes"> Yes </td>
2747627478
<td class="yes"> Yes </td>
27477-
<td>Specifies that the user agent must preemptively <span data-x="concept-fetch">fetch</span> and cache the target resource for current <span data-x="navigate">navigation</span> according to the <span data-x="concept-potential-destination">potential destination</span> given by the <code data-x="attr-link-as">as</code> attribute (and the <span data-x="concept-request-priority">priority</span> associated with the <span data-x="concept-potential-destination-translate">corresponding</span> <span data-x="concept-request-destination">destination</span>).</td>
27479+
<td>Specifies that the user agent must preemptively <span data-x="concept-fetch">fetch</span> and cache the target resource for current <span data-x="navigate">navigation</span> according to the <span>preload destination</span> given by the <code data-x="attr-link-as">as</code> attribute (and the <span data-x="concept-request-priority">priority</span> associated with the <span data-x="concept-potential-destination-translate">corresponding</span> <span data-x="concept-request-destination">destination</span>).</td>
2747827480
</tr>
2747927481

2748027482
<tr>
@@ -28340,6 +28342,10 @@ document.body.appendChild(wbr);</code></pre>
2834028342

2834128343
<p>A user agent must not <span>delay the load event</span> for this link type.</p>
2834228344

28345+
A <dfn>module preload destination</dfn> is "<code data-x="">json</code>", "<code
28346+
data-x="">style</code>", or a <span
28347+
data-x="concept-script-like-destination">script-like destination</span>.
28348+
2834328349
<div algorithm>
2834428350
<p>The appropriate times to <span>fetch and process the linked resource</span> for such a link
2834528351
are:</p>
@@ -28382,11 +28388,10 @@ document.body.appendChild(wbr);</code></pre>
2838228388
data-x="concept-request-destination">destination</span>), or "<code data-x="">script</code>" if
2838328389
it is in no state.</p></li>
2838428390

28385-
<li><p>If <var>destination</var> is not <span
28386-
data-x="concept-script-like-destination">script-like</span>, then <span>queue an element
28387-
task</span> on the <span>networking task source</span> given <var>el</var> to <span
28388-
data-x="concept-event-fire">fire an event</span> named <code data-x="event-error">error</code>
28389-
at <var>el</var>, and return.</p></li>
28391+
<li><p>If <var>destination</var> is not a <span>module preload destination</span>, then
28392+
<span>queue an element task</span> on the <span>networking task source</span> given <var>el</var>
28393+
to <span data-x="concept-event-fire">fire an event</span> named <code
28394+
data-x="event-error">error</code> at <var>el</var>, and return.</p></li>
2839028395

2839128396
<li><p>Let <var>url</var> be the result of <span>encoding-parsing a URL</span> given
2839228397
<var>el</var>'s <code data-x="attr-link-href">href</code> attribute's value, relative to
@@ -28800,9 +28805,8 @@ document.body.appendChild(wbr);</code></pre>
2880028805

2880128806
<p>The <code data-x="rel-preload">preload</code> keyword indicates that the user agent will
2880228807
preemptively <span data-x="concept-fetch">fetch</span> and cache the specified resource according
28803-
to the <span data-x="concept-potential-destination">potential destination</span> given by the
28804-
<code data-x="attr-link-as">as</code> attribute, and the <span
28805-
data-x="concept-request-priority">priority</span> given by the <code
28808+
to the <span>preload destination</span> given by the <code data-x="attr-link-as">as</code>
28809+
attribute, and the <span data-x="concept-request-priority">priority</span> given by the <code
2880628810
data-x="attr-link-fetchpriority">fetchpriority</code> attribute, as it is highly likely that the
2880728811
user will require this resource for the current navigation.
2880828812

@@ -28861,8 +28865,8 @@ document.body.appendChild(wbr);</code></pre>
2886128865
<dt><dfn data-x="preload URL">URL</dfn>
2886228866
<dd>A <span>URL</span>
2886328867

28864-
<dt><dfn data-x="preload destination">destination</dfn>
28865-
<dd>A string
28868+
<dt><dfn data-x="preload-key-destination">destination</dfn>
28869+
<dd>A <span>preload destination</span>
2886628870

2886728871
<dt><dfn data-x="preload mode">mode</dfn>
2886828872
<dd>A <span data-x="concept-request-mode">request mode</span>, either
@@ -28996,9 +29000,6 @@ document.body.appendChild(wbr);</code></pre>
2899629000
<li><p><var>destination</var> is "<code data-x="">font</code>" and
2899729001
<var>mimeTypeRecord</var> is a <span>font MIME type</span>;</p></li>
2899829002

28999-
<li><p><var>destination</var> is "<code data-x="">json</code>" and
29000-
<var>mimeTypeRecord</var> is a <span>JSON MIME type</span>;</p></li>
29001-
2900229003
<li><p><var>destination</var> is "<code data-x="">style</code>" and
2900329004
<var>mimeTypeRecord</var>'s <span data-x="MIME type essence">essence</span> is
2900429005
<code>text/css</code>; or</p></li>
@@ -29026,13 +29027,16 @@ document.body.appendChild(wbr);</code></pre>
2902629027
data-x="concept-request-credentials-mode">credentials mode</span>.</p>
2902729028
</div>
2902829029

29030+
A <dfn>preload destination</dfn> is "<code data-x="">fetch</code>", "<code
29031+
data-x="">font</code>", "<code data-x="">image</code>", "<code data-x="">script</code>", "<code
29032+
data-x="">style</code>", or "<code data-x="">track</code>".
29033+
2902929034
<div algorithm>
2903029035
<p>To <dfn>translate a preload destination</dfn> given a string <var>destination</var>:</p>
2903129036

2903229037
<ol>
29033-
<li><p>If <var>destination</var> is not "<code data-x="">fetch</code>", "<code data-x="">font</code>",
29034-
"<code data-x="">image</code>", "<code data-x="">script</code>", "<code data-x="">style</code>",
29035-
or "<code data-x="">track</code>", then return null.</p></li>
29038+
<li><p>If <var>destination</var> is not a <span>preload destination</span>, then return
29039+
null.</p></li>
2903629040

2903729041
<li><p>Return the result of <span
2903829042
data-x="concept-potential-destination-translate">translating</span>
@@ -153116,8 +153120,8 @@ interface <dfn interface>External</dfn> {
153116153120
<tr>
153117153121
<th> <code data-x="">as</code>
153118153122
<td> <code data-x="attr-link-as">link</code>
153119-
<td> <span data-x="concept-potential-destination">Potential destination</span> for a preload request (for <code data-x="attr-link-rel">rel</code>="<code data-x="rel-preload">preload</code>" and <code data-x="attr-link-rel">rel</code>="<code data-x="rel-modulepreload">modulepreload</code>")
153120-
<td> <span data-x="concept-potential-destination">Potential destination</span>, for <code data-x="attr-link-rel">rel</code>="<code data-x="rel-preload">preload</code>"; <span data-x="concept-script-like-destination">script-like destination</span>, for <code data-x="attr-link-rel">rel</code>="<code data-x="rel-modulepreload">modulepreload</code>"
153123+
<td> Destination for a preload request (for <code data-x="attr-link-rel">rel</code>="<code data-x="rel-preload">preload</code>" and <code data-x="attr-link-rel">rel</code>="<code data-x="rel-modulepreload">modulepreload</code>")
153124+
<td> <span>Preload destination</span>, for <code data-x="attr-link-rel">rel</code>="<code data-x="rel-preload">preload</code>"; <span>module preload destination</span>, for <code data-x="attr-link-rel">rel</code>="<code data-x="rel-modulepreload">modulepreload</code>"
153121153125
<tr>
153122153126
<th> <code data-x="">async</code>
153123153127
<td> <code data-x="attr-script-async">script</code>
@@ -157000,6 +157004,7 @@ INSERT INTERFACES HERE
157000157004
Kristof Zelechovski,
157001157005
Krzysztof Maczy&#x0144;ski,
157002157006
&#x9ed2;&#x6fa4;&#x525b;&#x5fd7; (Kurosawa Takeshi),
157007+
Kurt Catti-Schmidt,
157003157008
Kyle Barnhart,
157004157009
Kyle Hofmann<!-- Ozob -->,
157005157010
Kyle Huey,

0 commit comments

Comments
 (0)