Last updated on September 13, 2023

Disable Emojis

Don’t know where to add this snippet? Read our guide: How to add code snippets.

Remove all emoji related assets.

WordPress includes built-in support for emojis, but if you don’t use them on your site, they can slow down your website by loading extra JavaScript and CSS files. To disable emojis in WordPress, you can add the following code snippet:

function wpsnippets_disable_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' );
    add_filter( 'tiny_mce_plugins', 'wpsnippets_disable_emojis_tinymce' );
    add_filter( 'wp_resource_hints', 'wpsnippets_disable_emoji_dns_prefetch', 10, 2 );

function wpsnippets_disable_emojis_tinymce( $plugins ) {
    if ( is_array( $plugins ) ) {
        return array_diff( $plugins, array( 'wpemoji' ) );
    } else {
        return array();

function wpsnippets_disable_emoji_dns_prefetch( $urls, $relation_type ) {
   if ( 'dns-prefetch' === $relation_type ) {
      $emoji_url = apply_filters( 'emoji_svg_url', '' );
      $urls      = array_diff( $urls, array( $emoji_url ) );

   return $urls;

add_action('init', 'wpsnippets_disable_emojis');

This code removes the actions and filters that add the emoji scripts and styles to your site. It also disables the emoji plugin in the TinyMCE editor used for post and page editing. The wpsnippets_disable_emojis_tinymce function is used to remove the wpemoji plugin from the list of TinyMCE plugins. The wpsnippets_disable_emoji_dns_prefetch function is used to disable the DNS prefetch for the Emoji SVG url.

By disabling emojis, you can improve the performance of your WordPress site, especially on slower connections or devices. However, be aware that disabling emojis will also remove them from your content, comments, and post titles.

Last updated on September 13, 2023. Originally posted on May 3, 2023.

Leave a Reply

Your email address will not be published. Required fields are marked *