Lighthouse does not detect my use of modulepreload (recommends using preload)
See original GitHub issueProvide the steps to reproduce
- I ran Lighthouse on my site and got the following opportunity suggestion:
Note: I’m using <link rel="modulepreload">
instead of <link rel="preload">
.
What is the current behavior?
I’m getting a warning for something that I shouldn’t be getting a warning for. (Also, I’m not sure if the savings calculated is accurate since I am using modulepreload
).
What is the expected behavior?
For scripts loaded via <script type="module">
the recommendation should be to use modulepreload
(or perhaps recommend using one or the other).
Environment Information
- Affected Channels: CLI, DevTools
- Lighthouse version: 5.0
- Node.js version: v10.15.3
- Operating System: macOS 10.14.4
Related issues
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Preload key requests - Chrome Developers
The Opportunities section of your Lighthouse report flags the third level of requests in your critical request chain as preload candidates:.
Read more >Front-End Performance 2021: Build Optimizations
Let's make 2021... fast! An annual front-end performance checklist with everything you need to know to create fast experiences on the web ...
Read more >Optimizing resource loading with Priority Hints - web.dev
Priority Hints indicate the relative priority of resources to the browser. They can enable optimal loading and improve Core Web Vitals.
Read more >Chrome Dev Summit 2018 — Day 1 - Medium
This is the 6th Chrome Dev Summit, my first summit to attend in person meeting ... Not many developers know about this, it...
Read more >What's new for the Web — Google I/O 2018 | Bitcoin Insider
<link rel=”modulepreload” href=”lib.mjs” > (modulepreload is not a typo) Check the link here. The .mjs extension isn't required in the browser.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Interesting discussion here! Any new developments over the last year-and-a-half?
I just ran into the same issue where LH (likely falsely) claims I could save 3,000+ ms on a script that’s module-preloaded by adding
rel="preload"
. The url is https://sbsev.netlify.app/blog.Is this false claim related to the redirect warning in the LH results attached below? LH does not make the same claim when rerunning it on the redirect URL https://sbsev.netlify.app/blog/.
Hmmm, actually I think that article is correct and I was wrong.
modulepreload
(per the spec) does not require UAs to preload dependencies, and in my testing since filing this issue, it seems that Chrome does not preload dependencies. (I’m asking around to find out why.)Given that, it’s probably still good to recommend using
modulepreload
on all static (top-level) module dependencies, but I’m not sure if there’s a good way to determine that a module is not a top-level, static dependency.I don’t know of a good way via web APIs, but maybe the devtools protocol exposes this information somehow?
Related, I wonder if it makes sense for Lighthouse to warn if module scripts are preloaded with regular
<link rel=preload>
, as it sounds like doing that does not put them in the module graph.Again, I can ask around to see what the best practices are here.