Exclude WordPress core hooks/i18n from JS defer (inline translations call wp.i18n synchronously) - #1039
Open
Contributolo wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds
wp-includes/js/dist/hooksandwp-includes/js/dist/i18nto the predefined JS Deferred / Delayed Excludes, and to the predefined JS Excludes so the two files are not swallowed into a combined file where the defer exclude could no longer match.Why
On every localized site WordPress core prints inline scripts that call
wp.i18n.setLocaleData()synchronously:wp-i18n-js-afterplus one<handle>-js-translationsblock for each script that ships translations (Contact Form 7, WooCommerce, Elementor, block scripts, ...).With Load JS Deferred = Deferred the external
i18n.min.js/hooks.min.jsgetdefer, while those inline blocks still run immediately during parsing (inline JS is not deferred in Deferred mode). The result on every page load isThis reproduces deterministically across many sites on LSCWP 7.9 with Deferred enabled; adding the two files to the site-level excludes removes the errors.
hooksis a dependency ofi18n. Both files are tiny (about 2 KB and 5 KB minified), so keeping them synchronous has no measurable cost, unlike excluding jQuery, which should stay a per-site decision.Notes
.min.jssuffix also cover theSCRIPT_DEBUGvariants (hooks.js,i18n.js).a11yneeds no entry: its inline block only callswp.i18n.