Disable Emojicons Feature Introduced in New WordPress 4.2

How to Disable Emojicons Feature Introduced in New WordPress 4.2

in Functions
Google+ LinkedIn

With the release of new WordPress 4.2 version, WordPress team introduced the use of Emojicons in your posts and comments. In order to make this new Emojicons feature to work, WordPress automatically adds JavaScript libraries in your page. Although it’s a nice feature to have for some bloggers who use Emojicons very frequently, but for some, it might be another useless bloat which they will probably never going to use on their website. If you are one of them then you might be wondering, how to disable Emojicons to gain your website speed back. So let’s see how to disable Emojicons in WordPress 4.2.

In file /wp-includes/default-filters.php, WordPress adds all filters and actions that are used to add these Emojicons. All you need to do is find handle of each filters and actions and disallow WordPress to execute them using the functions remove_filter and remove_action. So here is the code snippet, you can paste in your functions.php file to disable Emojicons in your website.

// disable Emojicons in WordPress 4.2
function wpcs_remove_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 head tag
    remove_action( 'wp_head', 'print_emoji_detection_script', 7 );

    // Remove from print related styling
    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', 'wpcs_remove_emojicons' );

That’s it! Now you have disable Emojicons support on your website and removed all JavaScript libraries.

Share the love

If you like this snippet, share it with others!

Leave a Reply

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