Disable Emojicons on your WordPress site

A quick snippet to disable WordPress Emojicons and also remove the emojicon-specific CSS and JS.

Since version 4.2 release, WordPress now allows you to add the cool new Emojicons to your posts. In case you don’t know what emojicons are: they are the successor of Emoticons or smilies with more better graphics, and web platforms are quickly adopting them.

It was very easy to opt-out from using emoticons from the WordPress Writing Settings. As emojicons are succeeding emoticons, you can turn them off but this way you just can’t get rid of them completely:

Disabling WordPress emoticons

Emojicons can be turned off but they still add the code responsible for their styling and rendering.

But that is not enough. You still have the emojicons styles and JavaScript auto-enqueued in the header of your theme, which is unnecessary after you opted into not using emojicons.

Extra code added by WordPress emojicons

The extra bit of code added by WordPress emojicons—becomes useless when you don’t want

Removing WordPress Emojicons CSS and JS

As usual, WordPress (4.2+) hooks in some functions to implement the emojicons. In order to disable them, we need to unhook those functions with the help of some code.

Below given code snippet helps you to get rid of those extra bits of emojicon-specific CSS and JS from your WordPress themes. Remove the lines which don’t fit in your requirement:

function flush_emojicons() {
    // Remove from comment feed and RSS
    remove_filter( 'the_content_feed', 'wp_staticize_emoji' );
    remove_filter( 'comment_text_rss', 'wp_staticize_emoji' );

    // Remove from Emails
    remove_filter( 'wp_mail', 'wp_staticize_emoji_for_email' );

    // Remove from the head, i.e. wp_head()
    remove_action( 'wp_head', 'print_emoji_detection_script', 7 );

    // Remove from Print-related CSS
    remove_action( 'wp_print_styles', 'print_emoji_styles' );

    // Remove from Admin area
    remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
    remove_action( 'admin_print_styles', 'print_emoji_styles' );
add_action( 'init', 'flush_emojicons' );

Hope you found it useful. Cheers!