build(chore): switch to defer since it guarantees execution order once chunked#26425
build(chore): switch to defer since it guarantees execution order once chunked#26425HowardBraham merged 3 commits intodevelopfrom
defer since it guarantees execution order once chunked#26425Conversation
defer since it guarantees execution order once chunkeddefer since it guarantees execution order once chunked
|
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #26425 +/- ##
========================================
Coverage 69.99% 70.00%
========================================
Files 1424 1424
Lines 49984 49984
Branches 13872 13872
========================================
+ Hits 34986 34987 +1
+ Misses 14998 14997 -1 ☔ View full report in Codecov by Sentry. |
Builds ready [e254c6e]
Page Load Metrics (85 ± 7 ms)
Bundle size diffs
|
Gudahtt
left a comment
There was a problem hiding this comment.
Functionally I'd expect the only difference here to be that defer will wait for the HTML parsing to complete, whereas async will run before the HTML parsing is complete.
Probably defer is what we want here, as pausing parsing 2 lines before it's complete doesn't seem especially useful, and the JS bundle can't really make bunch benefit of that 2-line headstart.
The async versus ordered difference doesn't really come into play here because there's only one script being loaded.
But either way, LGTM!



asyncscript tags execute as soon as the script is downloaded, whereasdeferwill executes in DOM order. We useasyncin our bundle when chunked (by webpack), and this could result in the JS being executed out of order. I haven't actually seen this race condition occur, but it seems possible.