How to Disable Emojis in WordPress

Updated on November 09, 2017

There are a lot of web performance optimizations and tweaks you can do to make your WordPress site load faster.  One easy optimization is to disable emojis from loading. Emojis are little icons used to express ideas or emotions. While these icons are fun and all, are they really necessary for your WordPress site? Especially if you are a business, these are simply adding additional load time which is unnecessary.

disable emojis

When they released WordPress 4.2, they added support for emojis into core for older browsers. The big issue with this is that it generates an additional HTTP request on your WordPress site to load the wp-emoji-release.min.js file. And this loads on every single page. While this file is only 10.5 KB, things like these add up over time.

wp emoji release file

Disable Emojis in WordPress

There are a couple different ways to disable Emojis in WordPress. You can do it with a free plugin or with code.

1. Disable Emojis in WordPress With Plugin

The first way to disable emojis is to simply use a free plugin called Disable Emojis, developed by Ryan Hellyer.

disable emojis wordpress plugin

This plugin is super lightweight, only 9 KB to be exact. As of writing this, it currently has over 30,000 active installs with a 5 out of 5 star rating. Note: Emoticons and emojis will still work in browsers which have built in support for them. This plugin simply removes the extra JavaScript file that is used to add support for emojis in older browsers.

You can download it from the WordPress repository or by searching for it within your WordPress dashboard under “Add New” plugins. There is nothing to configure, simply install, activate, and the additional JavaScript file will be gone.

There is also a free alternative plugin called Emoji settings. This was built with Multisite in mind and gives the user an option to disable Emoji’s themselves.

emoji settings

You can download it from the WordPress repository or by searching for it within your WordPress dashboard under “Add New” plugins. Once activated, the user can check or uncheck “Enable emoji support” from within the Writing settings in their WordPress dashboard.

You could also use a premium plugin like perfmatters (developed by a team member at Kinsta), which allows you to disable emojis along with other optimizations for your WordPress site.

Disable emojis in perfmatters plugin

Disable emojis in perfmatters plugin

2. Disable Emojis in WordPress With Code

If you don’t want to install another plugin, you can also just disable emojis with code. Simply add the following to your WordPress theme’s functions.php file. Note: code sourced from Disable Emoji’s plugin above.

Important! Editing the source code of a WordPress theme could break your site if not done correctly. If you are not comfortable doing this, please check with a developer first.
/**
 * Disable the 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_filter( 'wp_resource_hints', 'disable_emojis_remove_dns_prefetch', 10, 2 );
}
add_action( 'init', 'disable_emojis' );

/**
 * Filter function used to remove the tinymce emoji plugin.
 * 
 * @param array $plugins 
 * @return array Difference betwen the two arrays
 */
function disable_emojis_tinymce( $plugins ) {
 if ( is_array( $plugins ) ) {
 return array_diff( $plugins, array( 'wpemoji' ) );
 } else {
 return array();
 }
}

/**
 * Remove emoji CDN hostname from DNS prefetching hints.
 *
 * @param array $urls URLs to print for resource hints.
 * @param string $relation_type The relation type the URLs are printed for.
 * @return array Difference betwen the two arrays.
 */
function disable_emojis_remove_dns_prefetch( $urls, $relation_type ) {
 if ( 'dns-prefetch' == $relation_type ) {
 /** This filter is documented in wp-includes/formatting.php */
 $emoji_svg_url = apply_filters( 'emoji_svg_url', 'https://s.w.org/images/core/emoji/2/svg/' );

$urls = array_diff( $urls, array( $emoji_svg_url ) );
 }

return $urls;
}
Was this article helpful?
No, or there was something off

Hand-picked related articles

Use WordPress?

Join 20,000+ others who get our FREE weekly newsletter with WordPress tips on how to drive more traffic and revenue to your business!

You have Successfully Subscribed!

Send this to a friend