mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-07-30 17:25:58 -04:00
Similar to https://github.com/lightpanda-io/browser/pull/2675. That PR added support for rel=preload, this one adds it for rel=modulepreload. The impact here is generally less significant. Modules were already asynchronously preloaded as part of the module-loading flow. What this does is potentially start the preload earlier (i.e. when the link is encountered). You can imagine: // pseudo-html <link rel=modulepreload href=mod1.js> <link rel=modulepreload href=mod2.j2> <script src=s1.js></script> <script src=s2.js></script> If s1.js imports mod1 and mod2, then there won't be a huge difference...I mean mod1 and mod2 can start loading before s1.js is complete, but it won't be huge. If s1.js doesn't import mod1 and/or mod2, but s2.js does, then the gain is a little more (because now we have to wait for both s1 and s2 to load). So it really depends. This commit also better manages preloaded scripts. There were common cases where a preloaded script might remain preloaded until page teardown..well past its actual usage. This happened because, while every preload increments the waiters count, only the first to fetch it decrements it. Once cached, waiters was never decremented. This is now fixed.
2 lines
39 B
JavaScript
2 lines
39 B
JavaScript
export const val = 'preloaded-module';
|