Dynamically added `<link rel=modulepreload` (or `link rel=preload as=script`) takes code-path for speculative loads in <ScriptLoader.cpp>
Categories
(Core :: Networking, defect, P3)
Tracking
()
People
(Reporter: mbrodesser-Igalia, Unassigned)
References
(Blocks 1 open bug)
Details
(Whiteboard: [necko-triaged])
STR:
- Open https://jsfiddle.net/nwgj1vd2/1/
- Open Network tab in Devtools.
- Click the "Run" button of the jsfiddle.
Expected: the Network tab shows that <dummy.js> is loaded with "Normal" priority, since it's not a speculative load (https://searchfox.org/mozilla-central/rev/aa8a99510c0686cdf9d42fb4b8f6d968884c961d/dom/script/ScriptLoader.cpp#714-715).
Actual: it's loaded with "Highest" priority.
Additional local logging showed the "Highest" priority stems from executing https://searchfox.org/mozilla-central/rev/aa8a99510c0686cdf9d42fb4b8f6d968884c961d/dom/script/ScriptLoader.cpp#713,720.
Reporter | ||
Updated•11 months ago
|
Comment 1•11 months ago
|
||
I'm a bit surprised that speculative loads have higher priority than normal loads.
With the exception that speculative loads have higher priority than normal loads, I would argue that the current code is correct. Due to rel=preload
being speculative by definition. Adding the speculative load via javascript doesn't change it's semantics.
If you want to non-speculatively load a script, just add a <script src="dummy.js"></script>
element instead. I think the bug is about speculative loads having higher priority than normal loads, taking the code path of "ScriptLoader.cpp" is correct.
Updated•11 months ago
|
Reporter | ||
Comment 2•11 months ago
|
||
(In reply to Manuel Bucher [:manuel] from comment #1)
I'm a bit surprised that speculative loads have higher priority than normal loads.
With the exception that speculative loads have higher priority than normal loads, I would argue that the current code is correct. Due to
rel=preload
being speculative by definition. Adding the speculative load via javascript doesn't change it's semantics.
Agree. I mixed speculative loading up with speculative parsing. Thanks for pointing this out.
If you want to non-speculatively load a script, just add a
<script src="dummy.js"></script>
element instead. I think the bug is about speculative loads having higher priority than normal loads, taking the code path of "ScriptLoader.cpp" is correct.
No. In case that's considered an issue, let's deal with it in a separate ticket.
Description
•