Make WordPress Core


Ignore:
Timestamp:
10/06/2025 04:49:13 AM (8 months ago)
Author:
westonruter
Message:

Emoji: Move printing of emoji loader script module from wp_head to wp_print_footer_scripts.

This removes ~3KB of HTML from the critical rendering path of markup in the head, thus marginally improving FCP/LCP in slower connections. It also fixes a Firefox issue with script modules by ensuring the emoji loader script module is printed after the importmap.

Existing plugins that disable emoji by unhooking the action as follows will continue to work as expected:

remove_action( 'wp_head', 'print_emoji_detection_script', 7 );

Additionally, some obsolete DOMReady and readyCallback logic was removed. A script module (as it has a deferred execution) only ever executes when the DOM is fully loaded. This means there was no need for a DOMContentLoaded event which was removed in [60899], and the remaining ready detection logic can be removed.

Follow-up to [60899].

Developed in https://github.com/WordPress/wordpress-develop/pull/10145.

Props westonruter, wildworks.
Fixes #63842.
Fixes #64076.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/formatting.php

    r60899 r60902  
    59135913    $printed = true;
    59145914
    5915     _print_emoji_detection_script();
     5915    if ( did_action( 'wp_print_footer_scripts' ) ) {
     5916        _print_emoji_detection_script();
     5917    } else {
     5918        add_action( 'wp_print_footer_scripts', '_print_emoji_detection_script' );
     5919    }
    59165920}
    59175921
Note: See TracChangeset for help on using the changeset viewer.