-
Notifications
You must be signed in to change notification settings - Fork 131
Delay loading detect module until page is loaded and idle #2017
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
Conversation
4deb0c7
to
8edcd7c
Compare
As of 305fff3, the extensions are now loaded in parallel: Before: ![]() After: ![]() |
… update/od-detect-loader
305fff3
to
4497b85
Compare
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
d46aa32
to
9b5f985
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## trunk #2017 +/- ##
========================================
Coverage ? 67.19%
========================================
Files ? 93
Lines ? 7751
Branches ? 0
========================================
Hits ? 5208
Misses ? 2543
Partials ? 0
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All looks good to me here too. Nothing more to add on my end 👍
The
detect
module is loaded via a dynamic import which involves a high fetch priority. No resources for Optimization Detective should ever compete with the loading of any resources for the critical rendering path. So this introduces an inlineddetect-loader
script module which explicitly waits for the page to be fully loaded and idle before beginning to load thedetect
module. This wait-until-idle logic was previously in thedetect
module itself, but it is better to put in inline on the page to delay the loading of the script module.Additionally, the client-side extensions for Optimization Detective (e.g. Image Prioritizer and Embed Optimizer) now get their extension modules loaded in parallel, further reducing the time between load and detection start.
On a single post template with the LCP element being the featured image, the impact on the LCP-TTFB metric are as follows (capturing the median of 50 requests):
Network Waterfall
Before
Note how Optimization Detective's
detect.js
is loaded concurrently with the LCP image resource. Note also how the extensions'detect.js
modules are loaded in series.After
Note how
detect.js
is loaded at theload
event, after the critical resources have been loaded. Note also how the extensions'detect.js
modules are loaded in parallel.