-
Notifications
You must be signed in to change notification settings - Fork 5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
perf: use an interstitial page to load popup.html
; load scripts using defer
ed script tags
#26555
Conversation
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 #26555 +/- ##
===========================================
+ Coverage 69.96% 70.11% +0.15%
===========================================
Files 1405 1412 +7
Lines 48996 49246 +250
Branches 13697 13769 +72
===========================================
+ Hits 34280 34527 +247
- Misses 14716 14719 +3 ☔ View full report in Codecov by Sentry. |
Builds ready [4d2b359]
Page Load Metrics (1655 ± 61 ms)
Bundle size diffs
|
This change drastically improves the performance of the extension but greatly reduces perceived performance because the browser won't display the popup until the DOMContentLoaded event. A work around for the reduction in perceived performance is in a follow up PR. Co-authored-by: Mark Stacey <[email protected]>
…s HTML file, `popup-init.html`, that then redirects to the slower `popup.html` Co-authored-by: Mark Stacey <[email protected]>
4d2b359
to
fcf6a91
Compare
Builds ready [fcf6a91]
Page Load Metrics (1629 ± 52 ms)
Bundle size diffs
|
popup.html
; load scripts use defer
ed script tagspopup.html
; load scripts using defer
ed script tags
83f0c20
Firefox is very slow to render the `popup-init.html` redirect, and it renders the page only partially anyway, making the UX feel very janky. It also doesn't delay opening the popup until `DOMContentLoaded`, like chrome does, so the issue `popup-init.html` solves doesn't do anything anyway.
83f0c20
to
22281d7
Compare
Quality Gate passedIssues Measures |
Builds ready [22281d7]
Page Load Metrics (2053 ± 149 ms)
Bundle size diffs
|
Missing release label release-12.2.0 on PR. Adding release label release-12.2.0 on PR and removing other release labels(release-12.5.0), as PR was cherry-picked in branch 12.2.0. |
This PR removes
load-*.js
helpers and load scripts using thedefer
property instead.This change drastically improves the performance of the extension but greatly reduces perceived performance because the browser won't display the popup until the DOMContentLoaded event.
But improve perceived performance is mostly regained by initially loading an asset-less HTML file,
popup-init.html
, that then redirects to the slower (but much faster than before this PR)popup.html
.This was initially authored by @Gudahtt, I've just updated and optimized it to work with the both build systems.
One change I did not make was moving scripts to the
head
. I don't think putting the scripts in the head does anything in our case1 other than potentially require that we wait forDOMContentLoaded
before querying for the app container.Note: In Firefox we continue to use
popup.html
. Firefox is very slow to render thepopup-init.html
redirect, and it renders the page only partially anyway, making the UX feel very janky. It also doesn't delay opening the popup untilDOMContentLoaded
, like Chrome does, so the issuepopup-init.html
solves doesn't do anything anyway.Here is side-by-side video comparison of
develop
vspopup-defer-scripts
.This video displays the elapsed time from clicking the MetaMask Fox to Lock Screen render.
The end of the video is a frame-by-frame comparison of the new "jank" this PR introduces. The develop branch renders the fox immediately, whereas the popup-defer-scripts branch renders an empty page for about 15 milliseconds.
These stats aren't representative of real world performance, but are intended to illustrate relative performance and perceived performance.
Both builds were created by running
yarn build dist
.develop-vs-propup-defer-scripts.mp4
Manual Testing
yarn dist
Closes #25721
Footnotes
our HTML files are very tiny, and thus will be loaded all in one go, we don't have to worry about packets being lost and retransmitted over the network, delaying the browser's preload scanner. ↩