Add <link> rel="modulepreload" #2383

Open
wants to merge 2 commits into
from

Projects

None yet

4 participants

@domenic
Member
domenic commented Feb 22, 2017

This allows preloading module script graphs. The processing model for
this turns out to be different enough that simply extending
rel="preload" is not a good option.

Closes whatwg/fetch#486.


/cc @whatwg/modules @yoavweiss

@domenic domenic Add <link> rel="modulepreload"
This allows preloading module script graphs. The processing model for
this turns out to be different enough that simply extending
rel="preload" is not a good option.

Closes whatwg/fetch#486.
60d74b0
@annevk
Member
annevk commented Feb 23, 2017 edited

If I have a document A with a same-origin <iframe> B. I think with a rel=preload in A I can get the resource cached for A and B. (Although this is somewhat unclear due to it not being defined...) With the setup you propose here you would get a new load for B. Is that what we want?

@@ -12307,6 +12329,7 @@ interface <dfn>HTMLLinkElement</dfn> : <span>HTMLElement</span> {
<code data-x="rel-alternate">alternate</code>,
<code data-x="rel-dns-prefetch">dns-prefetch</code>,
<code data-x="rel-icon">icon</code>,
+ <code data-x="rel-modulepreload">modulepreload</code>,
@zcorpan
zcorpan Feb 23, 2017 Member

Can we call it preloadmodule instead, so it's listed next to preload and autocomplete works better?

@domenic
domenic Feb 23, 2017 Member

That does seem reasonable. Will update and rename the PR.

@domenic
domenic Feb 23, 2017 Member

On second thought... "preloadmodule" sounds like "preload a module" ("why not just use preload??"), or maybe "a module specifying a bunch of preload stuff".

Whereas "modulepreload" sounds like "a module-specific variant of preload".

Seems better as-is to me now...

+
+ <li><p><span data-x="parse a url">Parse</span> the <span>URL</span> given by the <code
+ data-x="attr-link-href">href</code> attribute, relative to the element's <span>node
+ document</span>. If that fails, then abort these steps. Otherwise, let <var>url</var> be the
@zcorpan
zcorpan Feb 23, 2017 Member

Fire error here if w3c/preload#88 is so changed.

@domenic
Member
domenic commented Feb 23, 2017

If I have a document A with a same-origin <iframe> B. I think with a rel=preload in A I can get the resource cached for A and B. (Although this is somewhat unclear due to it not being defined...) With the setup you propose here you would get a new load for B. Is that what we want?

I didn't know that was true; I guess that falls into the same "preload cache is unspecified" bucket. But yes, this is definitely what we want; this is a great point as to why it has to be separate. Each document has a separate module map, and we don't want to introduce ways for one document to accidentally start overwriting the other document's module map.

source
+
+ <div w-nodev>
+
+ <p>The following contains are the appropriate times to fetch the resource for such a link:</p>
@sideshowbarker
sideshowbarker Feb 27, 2017 edited Member
<p>The following contains are the appropriate times to fetch the resource for such a link:</p>

Drop the word contains here?

source
+ <!-- integrity?? https://github.com/whatwg/html/issues/2382 -->
+
+ <li><p><span data-x="concept-fetch">Fetch</span> <var>request</var>, and asynchronously wait
+ to run the remaining steps as part of fetch's <span>process response</span> for the <span
@sideshowbarker
sideshowbarker Feb 27, 2017 Member
  to run the remaining steps as part of fetch's <span>process response</span> for the <span 

Add the before fetch here? So, as part of the fetch's process response

@domenic domenic Fix issues found by sideshowbarker
7bb6fc5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment