Commit b7b1441
committed
Emoji: Convert the emoji loader from an inline blocking script to a (deferred) script module.
This modernizes the emoji loader script by converting it from a blocking inline script with an IIFE to a script module. Using a script module improves the performance of the FCP and LCP metrics since it does not block the HTML parser. Since script modules are deferred and run immediately before `DOMContentLoaded`, the logic to wait until that event is also now removed. Additionally, since the script is loaded as a module, it has been modernized to use `const`, `let`, and arrow functions. The `sourceURL` comment is also added. See #63887.
The emoji settings are now passed via a separate `script` tag with a `type` of `application/json`, following the new "pull" paradigm introduced for exporting data from PHP to script modules. See #58873. The JSON data is also now encoded in a more resilient way according to #63851. When the `wp-emoji-loader.js` script module executes, it continues to populate the `window._wpemojiSettings` global for backwards-compatibility for any extensions that may be using it.
A new `uglify:emoji-loader` grunt task is added which ensures `wp-includes/js/wp-emoji-loader.js` is processed as a module and that top-level symbols are minified.
Follow-up to [60681].
Props westonruter, jonsurrell, adamsilverstein, peterwilsoncc.
See #63851, #63887.
Fixes #63842.
git-svn-id: https://develop.svn.wordpress.org/trunk@60899 602fd350-edb4-49c9-b593-d223f7449a821 parent d6bb737 commit b7b1441
File tree
4 files changed
+459
-414
lines changed- src
- js/_enqueues/lib
- wp-includes
- tests/phpunit/tests/formatting
4 files changed
+459
-414
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
838 | 838 | | |
839 | 839 | | |
840 | 840 | | |
| 841 | + | |
841 | 842 | | |
842 | 843 | | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
843 | 852 | | |
844 | 853 | | |
845 | 854 | | |
| |||
1549 | 1558 | | |
1550 | 1559 | | |
1551 | 1560 | | |
| 1561 | + | |
1552 | 1562 | | |
1553 | 1563 | | |
1554 | 1564 | | |
| |||
0 commit comments