diff --git a/src/js/_enqueues/lib/emoji-loader.js b/src/js/_enqueues/lib/emoji-loader.js index dfd5cd35438bf..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. /** @@ -12,15 +14,13 @@ * @property {?string} source.concatemoji * @property {?string} source.twemoji * @property {?string} source.wpemoji - * @property {?boolean} DOMReady - * @property {?Function} readyCallback */ 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-includes/js/wp-emoji.js (source file: js/_enqueues/wp/emoji.js). window._wpemojiSettings = settings; /** @@ -422,17 +422,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; - }; - } ) - .then( () => { // 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, 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' ); + } } /**