in

Combine External Javascript: Disable WP Emoji’s

Disable Emoji's in Wordpress

As of WordPress 4.2 the CMS platform supports Emoji’s. This could be great news for you, if you use them anywhere away from your mobile phone. However, for many bloggers the added feature is an absolute eyesore, causing combine external Javascript to reappear in Pingdom and Pagespeed Insights. Damn you, WordPress! If you introduce a new feature, at least allow us to disable it!

When you’re optimizing your WordPress website, you’ll notice that minification plugins aren’t able to capture the file. Which means that ‘wp-emoji-release.min.js’ will always show up as an extra DNS request. It also means that Pingdom and Google Pagespeed Insights will suggest you to combine external Javascript. It is a terrible thing if you already spent days fine-tuning your WordPress’ website performance.

Luckily, removing the feature isn’t that hard. Today I’ll show you how a few lines of code will send your WordPress website soaring towards that perfect score again.

Remove WP Emoji’s

Adding the following lines of code to your theme’s functions.php will remove all of the code from all the places where the emoji’s are hooked.

<?php
// Disable WP Emoji's
function 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', 'disable_emojis_tinymce' );
}
add_action( 'init', 'disable_emojis' );
// Disable TinyMCE Emoji's
function disable_emojis_tinymce( $plugins ) {
if ( is_array( $plugins ) ) {
return array_diff( $plugins, array( 'wpemoji' ) );
} else {
return array();
}
}
view raw disable-emojis.php hosted with ❤ by GitHub

The above solution is for those who are familiar with code and want to have as few plugins as possible running on their WordPress installation. For those of you who are not familiar with PHP, not comfortable touching your functions.php (that sounded weird) or are simply lazy, there is another solution. Ryan Hellyer has put the above code into a plugin, taking care of the entire process for you.

Combine External Javascript: Disable and Remove WP Emoji's

Screw you, “Combine External Javascript”!

Both solutions should disable wp emoji’s for you. Bringing your WordPress website back to its old highscore on Google Pagespeed Insights and Pingdom, cause it passed the combine external Javascript test again!

Happy days! 🙂

Buy me a beer?

Do you appreciate my work and support? Please consider supporting me by donating, so I can continue to develop and write useful solutions for you.

Choose amount

Personal Message

Thank you! 🙂

Written by Daan van den Bergh

Magento 2 Back-end Developer with a passion for trainlifting, airplane-gliding, hunting trees and creating fake hobbies.

2 Comments

Leave a 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.