Closed Bug 1861975 Opened 11 months ago Closed 11 months ago

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)

defect

Tracking

()

RESOLVED INVALID

People

(Reporter: mbrodesser-Igalia, Unassigned)

References

(Blocks 1 open bug)

Details

(Whiteboard: [necko-triaged])

STR:

  1. Open https://jsfiddle.net/nwgj1vd2/1/
  2. Open Network tab in Devtools.
  3. 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.

Summary: Dynamically added `<link rel=modulepreload` takes code-path for speculative loads in <ScriptLoader.cpp> → Dynamically added `<link rel=modulepreload` (or `link rel=preload as=script`) takes code-path for speculative loads in <ScriptLoader.cpp>

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.

Severity: -- → S4
Priority: -- → P3
Whiteboard: [necko-triaged]

(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.

Status: NEW → RESOLVED
Closed: 11 months ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.