Skip to content

build(chore): switch to defer since it guarantees execution order once chunked#26425

Merged
HowardBraham merged 3 commits intodevelopfrom
webpack-defer
Aug 16, 2024
Merged

build(chore): switch to defer since it guarantees execution order once chunked#26425
HowardBraham merged 3 commits intodevelopfrom
webpack-defer

Conversation

@davidmurdoch
Copy link
Copy Markdown
Contributor

@davidmurdoch davidmurdoch commented Aug 14, 2024

async script tags execute as soon as the script is downloaded, whereas defer will executes in DOM order. We use async in 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.

@davidmurdoch davidmurdoch changed the title switch to defer since it guarantees execution order once chunked build(chore): switch to defer since it guarantees execution order once chunked Aug 14, 2024
@github-actions
Copy link
Copy Markdown
Contributor

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.

@sonarqubecloud
Copy link
Copy Markdown

@codecov
Copy link
Copy Markdown

codecov bot commented Aug 14, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 70.00%. Comparing base (c5c13d5) to head (e254c6e).
Report is 4 commits behind head on develop.

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.
📢 Have feedback on the report? Share it here.

@metamaskbot
Copy link
Copy Markdown
Collaborator

Builds ready [e254c6e]
Page Load Metrics (85 ± 7 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint871671152311
domContentLoaded5712282189
load6412285157
domInteractive126935168
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

@davidmurdoch davidmurdoch marked this pull request as ready for review August 15, 2024 14:33
@davidmurdoch davidmurdoch requested a review from a team as a code owner August 15, 2024 14:33
Copy link
Copy Markdown
Member

@Gudahtt Gudahtt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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!

@HowardBraham HowardBraham merged commit eff95c7 into develop Aug 16, 2024
@HowardBraham HowardBraham deleted the webpack-defer branch August 16, 2024 15:57
@github-actions github-actions bot locked and limited conversation to collaborators Aug 16, 2024
@metamaskbot metamaskbot added the release-12.5.0 Issue or pull request that will be included in release 12.5.0 label Aug 16, 2024
@gauthierpetetin gauthierpetetin added release-12.4.0 Issue or pull request that will be included in release 12.4.0 and removed release-12.5.0 Issue or pull request that will be included in release 12.5.0 labels Sep 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-12.4.0 Issue or pull request that will be included in release 12.4.0 team-extension-platform Extension Platform team webpack

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

5 participants