How to Disable Emojis in WordPress for Better Speed

You don’t need any introduction about emojis. You see it often in text messages and conversations. They are enabled on your phone too. These small icons help to convey emotions or meanings easier than words.

WordPress by default supports the use of emojis. However, unless your blog has a personal nature, you might not require feature at all and need to disable it. WordPress loads additional scripts for emojis on all pages even if you use it or not. This includes an HTTP request too – wp-emoji-release.min.js.

For performance reasons, we are mainly interested in removing emojis from our front-end. It involves these things:

  1. Remove the inline script for emojis
  2. Disable the inline emoji styles
  3. Prevent the request for wp-emoji-release.min.js. The first step – removing the inline script – automatically takes care of this.
Emojis in the front-end and the action hooks that loaded them
The JS file – Using Chrome Dev Tools

In addition to these, we will also remove it from loading in the following areas:

  • WordPress admin
  • RSS feeds
  • Embeds
  • Emails
  • TinyMCE editor

Ways to Disable Emojis

So let us see how you can do this manually or by using plugins. If you want to avoid another plugin, I would suggest the manual way. If not, it’s okay and there are a couple of plugins which can do it for you.

Manual Method

function disable_emoji_feature() {
	
	// Prevent Emoji from loading on the front-end
	remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
	remove_action( 'wp_print_styles', 'print_emoji_styles' );

	// Remove from admin area also
	remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
	remove_action( 'admin_print_styles', 'print_emoji_styles' );

	// Remove from RSS feeds also
	remove_filter( 'the_content_feed', 'wp_staticize_emoji');
	remove_filter( 'comment_text_rss', 'wp_staticize_emoji');

	// Remove from Embeds
	remove_filter( 'embed_head', 'print_emoji_detection_script' );

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

	// Disable from TinyMCE editor. Currently disabled in block editor by default
	add_filter( 'tiny_mce_plugins', 'disable_emojis_tinymce' );

	/** Finally, disable it from the database also, 
	 *  to prevent characters from converting
	 *  Earlier, there was a setting under Writings to do this
	 *  It is not ideal to get & update it here - but it works for now
	 */

	if( (int) get_option('use_smilies') === 1 ) {
		update_option( 'use_smilies', 0 );
	}

}

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

add_action('init', 'disable_emoji_feature');

Basically, what we have done is to unhook all filters and actions that added the support for emojis. Earlier, there was an Option to uncheck emoji support under the Writings section. However, it is missing for some reason. That’s what the last part of our function is doing.

You can paste this code in the functions.php file of your child theme. Alternately, you can also add it to a site-specific plugin.

Note that it won’t be wise to add it directly to the functions.php file of a parent theme since the next theme update can wipe out all these changes you have made.

Disable Emojis using Plugins

So, if don’t have a child theme, use the following plugins.

Disable Emojis (GDPR Friendly)

It is a very lightweight plugin with just one PHP file and under a hundred lines of code. So don’t hesitate to install it since it will not slow down your site. In fact, the code I have given above is inspired by this plugin.

Visit Plugin Page

Disable Emoji WordPress

The plugin has no settings or other options. Just install it and you are good to go. It is as simple as that.

Autoptimize

This is not a plugin to disable emojis. But it includes the option for it. So if you are already using Autoptimize to minify and concatenate WordPress files, then no need of another plugin or custom code.

Visit Plugin Page

WordPress Disable Emoji using Autoptimize
Autoptimize emoji setting

You can locate the option under the Extra tab of the plugin’s Settings page.

Even if you disable it from WordPress, emojis will still show on your site if the visitor’s device support it. To completely switch it off, you have to do one more thing – prevent

Hope it was useful.

Sharing is caring!

1 thought on “How to Disable Emojis in WordPress for Better Speed

Leave a Reply

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

shares