HomeMethod

Knowledge

Web VitalsTechniquesSnippetsAnswersImpactsBottlenecks

Disable WordPress emoji scripts

  • Performance

WordPress loads an emoji detection script and stylesheet on every page — about 46 KB combined. These assets detect whether the browser supports native emoji and fall back to Twitter’s Twemoji images if not. Every modern browser has supported native emoji for years, making this entirely unnecessary.

disable-emojis.php
<?php
/**
 * Disable WordPress Emoji Scripts
 *
 * Removes the emoji detection script (~46 KB), inline styles, TinyMCE plugin,
 * and DNS prefetch hint that WordPress loads on every page. Safe to remove
 * unless your content relies on WordPress's emoji CDN rendering.
 *
 * Usage: Add to functions.php or a custom plugin.
 *
 * @category performance
 * @language php

 *
 * @author Adame Dahmani https://adame.io
 * @support Support my family project: https://adame.io/fundraiser
 */
add_action( 'init', function () {
    remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
    remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
    remove_action( 'wp_print_styles', 'print_emoji_styles' );
    remove_action( 'admin_print_styles', 'print_emoji_styles' );
    remove_filter( 'the_content_feed', 'wp_staticize_emoji' );
    remove_filter( 'comment_text_rss', 'wp_staticize_emoji' );
    remove_filter( 'wp_mail', 'wp_staticize_emoji_for_email' );

    add_filter( 'tiny_mce_plugins', function ( $plugins ) {
        return array_diff( $plugins, [ 'wpemoji' ] );
    } );

    add_filter( 'wp_resource_hints', function ( $urls, $relation_type ) {
        if ( $relation_type === 'dns-prefetch' ) {
            $urls = array_filter( $urls, function ( $url ) {
                return strpos( $url, 'https://s.w.org/images/core/emoji' ) === false;
            } );
        }
        return $urls;
    }, 10, 2 );
} );

This removes the detection script, inline styles, TinyMCE plugin, and the DNS prefetch hint for the emoji CDN. Safe to use unless your content relies specifically on WordPress’s Twemoji rendering (the Twitter-style emoji images).

Support our family now