WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.33k stars 4.12k forks source link

`wp-i18n` always loads in the `<head>` #64614

Open sgomes opened 4 weeks ago

sgomes commented 4 weeks ago

Description

39497 introduced a workaround for the bugs described in https://core.trac.wordpress.org/ticket/55628 and https://core.trac.wordpress.org/ticket/6195

Unfortunately, this workaround introduced a performance regression for every page where wp-i18n is enqueued.

wp-i18n isn't too large a script, but it does depend on the considerably larger wp-polyfill, which as a result also gets enqueued in <head>. From a performance point of view, it would be a nice win if we managed to fix this in a different way, since scripts in the <head> are render-blocking and can thus have an impact on first paint and all subsequent paint metrics.

Step-by-step reproduction instructions

Screenshots, screen recording, code snippet

No response

Environment info

No response

Please confirm that you have searched existing issues in the repo.

Please confirm that you have tested with all plugins deactivated except Gutenberg.

sgomes commented 1 week ago

CC @jsnajdr, who wrote an extensive analysis of the issue previously.

Hey @jsnajdr! 👋 It's been a while since this workaround was put in place. Are you aware of a better approach we could use now, to avoid having to place this script in the <head>?

jsnajdr commented 1 week ago

If it's only (or mainly) about wp-i18n, some good solutions could be:

sgomes commented 1 week ago

Thank you, @jsnajdr! Those are some good options I hadn't considered 👍

swissspidy commented 2 hours ago

To confirm, this is only an issue in Gutenberg because of the way GB overrides scripts?

From what I can see, wp-i18n and wp-polyfill in core are both registered to be in the footer, so maybe nowadays GB could try that as well?

Of course removing unnecessary dependencies is always a great option.