Open Bug 1425310 (modulepreload) Opened 5 years ago Updated 1 month ago

Implement link rel="modulepreload"


(Core :: DOM: Core & HTML, enhancement, P3)

55 Branch




(Reporter: d, Unassigned, NeedInfo)


(Blocks 3 open bugs)


(Keywords: dev-doc-needed)

modulepreload is a new link relation that behaves similar to preload, but different in several key ways. For example, it interprets its attributes and changes to them differently; it uses the module map instead of the preload cache; and it allows optionally fetching descendant modules as an optimization.


Priority: -- → P3
Preloading is currently disabled and will be re-enabled by bug 1394778.
Depends on: 1394778
FWIW the processing module for modulepreload is unrelated to that for preload so I don't think bug 1394778 is actually a dependency.

Until recently (I'd need to parse Firefox versions to confirm when this occurred), web pages could leverage rel="preload" to ensure the early download of a JS file (and as spec'd early parsing) regardless of whether the script was later loaded as type="module" or not. However, the current experience is that while the preload occurs, a script included in the page as type="module" is then downloaded a second time. See as an example as discussed in

It seems Chrome is likely to move to this more strict interpretation of the rel="preload" spec and pages will need to move to rel="modulepreload" to get performance benefits in type="module" scripts anywhere, so I was hoping it would be possible to get an update on whether Firefox saw this as something they'd be able to implement.

I think <link rel="modulepreload"> is currently one of the most important features to be implemented in Gecko, as pages load a lot slower without this.

Without modulepreload, the user agent must first download the primary JavaScript file before it can download its dependencies specified in an ES6 import. These imported JavaScript modules can import other modules as well, and so on. Because of this, the user agent has to make several network requests successively instead of making them all at once in parallel. This results in a noticeably slower page loading speed.

To better illustrate this, here is a screenshot of Chromium's waterfall of JavaScript files of some website of mine and here is the same website's JavaScript files download timeline in Firefox. Notice how without modulepreload support, Gecko has to wait for the first file to be downloaded before it can download the other files imported by it. These files themselves import other files which then also import yet another set of files. Blink however can download all JavaScript files in parallel, which results in a ~4 times better loading speed.

Blink is currently the only browser engine that supports this, which is a shame because preloading JavaScript modules is an essential thing that modern browsers are supposed to support. This has been specified for over five years now in the official HTML specification, which is another reason to implement this. As @Westbrook already pointed out, there is no way to polyfill this feature with things like <link rel="preload">.

Jon, is this worth re-triaging, perhaps?

Flags: needinfo?(jcoppeard)

I'm a maintainer of Svelte / SvelteKit and contributor to Vite, which are large and growing projects in the JS ecosystem ( We are using ESM modules almost exclusively and are seeing more and more of the JS ecosystem moving this direction. Vite and SvelteKit provide modulepreload on all pages out-of-the-box and performance is greatly improved in Chrome compared to Firefox as a result. I would find it very valuable if the priority and severity were bumped on this one.

I saw that was marked as duplicate of this, are Mozilla in favor of implementing modulepreload also in link headers? See spec PR:

(In reply to Noam Rosenthal from comment #8)

I saw that was marked as duplicate of this, are Mozilla in favor of implementing modulepreload also in link headers? See spec PR:

As there was no feedback on this question and they are actually two different features, I've reopened bug 1773056 now. Though Yoshi, feel free to mark the other bug as duplicate again if you think both the HTML attribute and the HTTP header will be implemented in this bug.


Severity: normal → S3
Blocks: 1798319
You need to log in before you can comment on or make changes to this bug.