Disable WordPress Emoji Scripts with a Code Snippet

Marek D. Dec 27, 2024 Performance Optimization
How can I turn off those little smiley face icons that show up in my website?
What code snippet can I implement to disable the default WordPress emoji scripts and improve site performance?
Andy answered Dec 27, 2024

Disable WordPress Emoji Scripts

Custom Code Solution

Add this code to your theme's functions.php file or in a site-specific plugin. This code removes emoji-related scripts and styles that WordPress adds by default:

function disable_wp_emojis() {
    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');

    // Remove the DNS prefetch
    add_filter('emoji_svg_url', '__return_false');

    // Remove TinyMCE emojis
    add_filter('tiny_mce_plugins', 'disable_emojis_tinymce');
}
add_action('init', 'disable_wp_emojis');

// Filter function to remove the TinyMCE emoji plugin
function disable_emojis_tinymce($plugins) {
    if (is_array($plugins)) {
        return array_diff($plugins, array('wpemoji'));
    }
    return array();
}

This solution:

  • Removes emoji detection script from front-end and admin
  • Removes emoji styles
  • Disables emoji in RSS feeds
  • Removes emoji from emails
  • Disables DNS prefetch for emoji
  • Removes emoji support from TinyMCE editor

Plugin Solutions

If you prefer a plugin-based approach, here are reliable options:

  1. Disable Emojis - Simple, lightweight plugin that only handles emoji removal
  2. Asset CleanUp - More feature-rich plugin that can disable emojis along with other WordPress optimizations

Performance Impact

Disabling WordPress emojis can:

  • Reduce HTTP requests
  • Remove unnecessary JavaScript
  • Decrease page load time
  • Save approximately 14KB of data per page load

Additional Notes

  • The code is safe to use and won't break any core WordPress functionality
  • If you need emojis later, simply remove the code
  • Some themes might already include similar functionality
  • This solution works for WordPress 5.0 and above