From 4a334e8f370dda29488b42c8da0900127edb8668 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Fri, 3 Oct 2025 20:42:45 -0700 Subject: [PATCH 1/6] Print emoji loader at wp_print_footer_scripts instead of wp_head --- src/wp-includes/formatting.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/wp-includes/formatting.php b/src/wp-includes/formatting.php index 44a7e6b085c76..141b245548053 100644 --- a/src/wp-includes/formatting.php +++ b/src/wp-includes/formatting.php @@ -5912,7 +5912,11 @@ function print_emoji_detection_script() { $printed = true; - _print_emoji_detection_script(); + if ( did_action( 'wp_print_footer_scripts' ) ) { + _print_emoji_detection_script(); + } else { + add_action( 'wp_print_footer_scripts', '_print_emoji_detection_script' ); + } } /** From 5afbdcb5ba0831118c5f6a722b13a68c91947950 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Fri, 3 Oct 2025 20:43:02 -0700 Subject: [PATCH 2/6] Remove unnecessary then --- src/js/_enqueues/lib/emoji-loader.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/js/_enqueues/lib/emoji-loader.js b/src/js/_enqueues/lib/emoji-loader.js index dfd5cd35438bf..717d2c879b64b 100644 --- a/src/js/_enqueues/lib/emoji-loader.js +++ b/src/js/_enqueues/lib/emoji-loader.js @@ -427,8 +427,7 @@ new Promise( ( resolve ) => { settings.readyCallback = () => { settings.DOMReady = true; }; - } ) - .then( () => { + // When the browser can not render everything we need to load a polyfill. if ( ! settings.supports.everything ) { settings.readyCallback(); From d8845a03e0d9b086ac1f85ce2e6b3dd2e1c9f603 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Fri, 3 Oct 2025 21:08:07 -0700 Subject: [PATCH 3/6] Remove apparently unnecessary DOMReady and readyCallback --- src/js/_enqueues/lib/emoji-loader.js | 10 ---------- src/js/_enqueues/wp/emoji.js | 11 +---------- 2 files changed, 1 insertion(+), 20 deletions(-) diff --git a/src/js/_enqueues/lib/emoji-loader.js b/src/js/_enqueues/lib/emoji-loader.js index 717d2c879b64b..4dbbef690ed38 100644 --- a/src/js/_enqueues/lib/emoji-loader.js +++ b/src/js/_enqueues/lib/emoji-loader.js @@ -12,8 +12,6 @@ * @property {?string} source.concatemoji * @property {?string} source.twemoji * @property {?string} source.wpemoji - * @property {?boolean} DOMReady - * @property {?Function} readyCallback */ const settings = /** @type {WPEmojiSettings} */ ( @@ -422,16 +420,8 @@ new Promise( ( resolve ) => { settings.supports.everythingExceptFlag && ! settings.supports.flag; - // Sets DOMReady to false and assigns a ready function to settings. - settings.DOMReady = false; - settings.readyCallback = () => { - settings.DOMReady = true; - }; - // When the browser can not render everything we need to load a polyfill. if ( ! settings.supports.everything ) { - settings.readyCallback(); - const src = settings.source || {}; if ( src.concatemoji ) { diff --git a/src/js/_enqueues/wp/emoji.js b/src/js/_enqueues/wp/emoji.js index 34012e96cec08..05582de672662 100644 --- a/src/js/_enqueues/wp/emoji.js +++ b/src/js/_enqueues/wp/emoji.js @@ -277,16 +277,7 @@ return twemoji.parse( object, params ); } - /** - * Initialize our emoji support, and set up listeners. - */ - if ( settings ) { - if ( settings.DOMReady ) { - load(); - } else { - settings.readyCallback = load; - } - } + load(); return { parse: parse, From ca22ac9f3b4319880322c992458d2c2775dcca39 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Fri, 3 Oct 2025 21:08:45 -0700 Subject: [PATCH 4/6] Update comment to note importance of wp-emoji.js reading from window._wpemojiSettings --- src/js/_enqueues/lib/emoji-loader.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js/_enqueues/lib/emoji-loader.js b/src/js/_enqueues/lib/emoji-loader.js index 4dbbef690ed38..c3c91fbd73dd2 100644 --- a/src/js/_enqueues/lib/emoji-loader.js +++ b/src/js/_enqueues/lib/emoji-loader.js @@ -18,7 +18,7 @@ const settings = /** @type {WPEmojiSettings} */ ( JSON.parse( document.getElementById( 'wp-emoji-settings' ).textContent ) ); -// For compatibility with other scripts that read from this global. +// For compatibility with other scripts that read from this global, in particular wp-emoji.js. window._wpemojiSettings = settings; /** From 5f83576286d174754741ec6e8447144b4a85ab9f Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Sun, 5 Oct 2025 17:06:44 -0700 Subject: [PATCH 5/6] Clarify where wp-emoji.js is --- src/js/_enqueues/lib/emoji-loader.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js/_enqueues/lib/emoji-loader.js b/src/js/_enqueues/lib/emoji-loader.js index c3c91fbd73dd2..fd98593375d63 100644 --- a/src/js/_enqueues/lib/emoji-loader.js +++ b/src/js/_enqueues/lib/emoji-loader.js @@ -18,7 +18,7 @@ const settings = /** @type {WPEmojiSettings} */ ( JSON.parse( document.getElementById( 'wp-emoji-settings' ).textContent ) ); -// For compatibility with other scripts that read from this global, in particular wp-emoji.js. +// For compatibility with other scripts that read from this global, in particular wp-includes/js/wp-emoji.js (source file: js/_enqueues/wp/emoji.js). window._wpemojiSettings = settings; /** From 41043013a88ad56b0c80dda4fc6a5f662a1d8d2b Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Sun, 5 Oct 2025 21:23:36 -0700 Subject: [PATCH 6/6] Add eslint-env es6 comment --- src/js/_enqueues/lib/emoji-loader.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/js/_enqueues/lib/emoji-loader.js b/src/js/_enqueues/lib/emoji-loader.js index fd98593375d63..0cdda5e0a0af5 100644 --- a/src/js/_enqueues/lib/emoji-loader.js +++ b/src/js/_enqueues/lib/emoji-loader.js @@ -2,6 +2,8 @@ * @output wp-includes/js/wp-emoji-loader.js */ +/* eslint-env es6 */ + // Note: This is loaded as a script module, so there is no need for an IIFE to prevent pollution of the global scope. /**