-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Load the import map polyfill only when there is an import map #56699
Load the import map polyfill only when there is an import map #56699
Conversation
This pull request has changed or added PHP files. Please confirm whether these changes need to be synced to WordPress Core, and therefore featured in the next release of WordPress. If so, it is recommended to create a new Trac ticket and submit a pull request to the WordPress Core Github repository soon after this pull request is merged. If you're unsure, you can always ask for help in the #core-editor channel in WordPress Slack. Thank you! ❤️ View changed files❔ lib/experimental/interactivity-api/modules.php ❔ lib/experimental/modules/class-gutenberg-modules.php |
This didn't improve the LCP metrics, so I'll do more tests.
|
The regression was close to 5%. and the margin of error can reach 5% as well in a single run but over multiple runs you can clearly see the trend. So this PR shows 1% diff, best is to try to run again to confirm whether the numbers are consistent. So yeah it's most likely not reverting the regression entirely/yet. |
These are the results without the polyfill:
|
If the polyfill is not the problem, I need to dig deeper to find out what's going on, because I can't imagine modules being slower than deferred scripts. |
This reverts commit af5eaad.
Flaky tests detected in 063c18d. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/7085116154
|
Even though this doesn't fix the LCP issue, we should merge it because it improves the current logic. I'll keep investigating the LCP issue in other PRs. |
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.
Tested and working as described. LGTM
I think for classic themes, this PR seem to have restored the previous numbers for LCP but it had no impact on block themes. |
That's great news because it means it's the polyfill, and all we need to do is load it only when the browser doesn't support import maps, which I tried and didn't succeed, but should be technically possible. |
For reference, we'll work on a new build of |
@gziolo made it work using |
What?
Load the import map polyfill only when there is an actual import map.
Why?
Because if there is no import map, it's not needed.
How?
By checking if the import map is empty before adding it to the HTML.
I also tried to load the polyfill conditionally by using this logic, but in my testing with iOS Safari 16.0 it didn't work.
This is the related issue in the
es-module-shims
repository:I'll investigate why it didn't work. For now, I think this fix improves the current behavior.
Testing Instructions
Also, in not supported browsers (Safari < 16.3):