As of WordPress 4.2, a new feature was introduced that allows you to use the new Emojis. While on some WordPress setups are useful, in many situations, especially when you are not using WordPress as a blog, you just don’t need them and the file /wp-includes/js/wp-emoji-release.min.js is loaded along with extra inline JavaScript code.

As I want my page to load as fast as possible and have the HTML code clean when analyzing the source code (as a developer), I’d rather have all that extra code removed, especially since it loads on every page of my website. There are two ways in which you can do that, depending on your circumstances.

1) Use the code snippet below:

You can edit functions.php or have a custom plugin with snippets as the block of code is pretty small. If you are comfortable with that, here’s the code that you can use:

function gl_disable_wp_emojicons() {
    // Remove actions and filters related to Emojis
    remove_action( 'admin_print_styles', 'print_emoji_styles' );
    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_filter( 'wp_mail', 'wp_staticize_emoji_for_email' );
    remove_filter( 'the_content_feed', 'wp_staticize_emoji' );
    remove_filter( 'comment_text_rss', 'wp_staticize_emoji' );

    // Filter to remove TinyMCE Emojis
    add_filter( 'tiny_mce_plugins', 'gl_disable_emojicons_tinymce' );
}

add_action( 'init', 'gl_disable_wp_emojicons' );

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

2) Using a plugin

No access to edit your PHP files or don’t feel comfortable doing it? You can achieve the same thing by installing a plugin, suh as Asset CleanUp.

disable emojis
This is the quickest way to do that and Emojis will still work in browsers which have built-in support for them. This plugin simply removes the extra code bloat used to add support for emoji in older browsers. You just need to activate the plugin, go to “Settings” -> “Site-Wide Common Unloads” -> and turn on “Disable Emojis Site-Wide?”.

Note: If you prefer to have the old smilies from previous WordPress versions, while removing the new ones, you can use Classic Smilies plugin.

2 Comments

  1. Thanks for this but it seems your forgot to mention that another amazing plugin named “Asset Cleanup” is also doing the job…;)

    It would be nice to have a subscription box for your blog posts!
    Why not? Is this intentional?

    Reply

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.