As of WordPress 4.2, a new feature was introduced that allows you to use the new Emojis. While on some WordPress setups is 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 2 ways in which you can do that. We’ll start with the most convenient one:
1) Disable Emojis plugin
This is the quickest way to do that and emoji 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.
2) Use the code below
I prefer to edit functions.php or to 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 bit_disable_wp_emojicons() { // all actions 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', 'bit_disable_emojicons_tinymce' ); } add_action( 'init', 'bit_disable_wp_emojicons' ); function bit_disable_emojicons_tinymce( $plugins ) { if ( is_array( $plugins ) ) { return array_diff( $plugins, array( 'wpemoji' ) ); } else { return array(); } }
Great snippet. Thanks