emojis on eggs

Removing all styles and scripts associated with WordPress core emojis in 2024

There are many tutorials on removing emojis from your source code in WordPress, but a lot of those posts are outdated and don’t give you the updated picture. There have been some changes to the WordPress core, and if you really want to catch everything, here’s the way to do it!

The code’s comments explain what each line does if you only need it in specific circumstances:

// removes emojis from the admin
remove_action( 'admin_print_scripts', 'print_emoji_detection_script ');
remove_action( 'admin_print_styles', 'print_emoji_styles ');
// removes emojis from the front end
remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
remove_action( 'wp_print_styles', 'print_emoji_styles ');
// removes emojis from the RSS feed
remove_filter( 'embed_head', 'print_emoji_detection_script' );
// removes emojis from comments
remove_filter( 'the_content_feed', 'wp_staticize_emoji ');
remove_filter( 'comment_text_rss', 'wp_staticize_emoji ');
// removes emojis from emails
remove_filter( 'wp_mail', 'wp_staticize_emoji_for_email ');
// removes the translation of emojis from someone's mobile device 
add_filter( 'option_use_smilies', '__return_false' );
// removes the injection of the inline CSS in the front end
add_action( 'wp_enqueue_scripts', function() {
    wp_dequeue_style( 'wp-emoji-styles' );
// removes extra nonsense from emojis
add_action( 'init', function( $plugins ) {
    if( is_array($plugins) ) {
        $plugins = array_diff( $plugins, array( 'wpemoji' ) );
    return $plugins;
} );
// removes the SVG prefetch url
add_filter( 'emoji_svg_url', '__return_false' );
add_filter( 'wp_resource_hints', function($urls, $relation_type) {
    if ( 'dns-prefetch' === $relation_type ) {
        // Strip out any URLs referencing the emoji script
        $emoji_svg_url_pattern = "/https:\/\/s.w.org\/images\/core\/emoji\//";
        foreach ( $urls as $key => $url ) {
            if ( preg_match( $emoji_svg_url_pattern, $url ) ) {
    return $urls;
}, 20, 2);

Adding this to your functions.php file will take care of all those annoying emojis. I wish this could just be a single filter that WordPress supports, but for now, all this code will get rid of the emojis for the last time.

I also wrote about the most pesky of the emoji styles to remove.