Learn About The Web

How to Disable Emojis in WordPress

emoji wordpress

To make your WordPress website load faster and perform better, there are plenty of tweaks that you can do. One of the easiest is to stop emojis from loading on your website.

These are used for expression emotions or ideas and, while they may be good fun, you need to consider if they are necessary. They do add to the page load time which, if they are not necessary, is not good news.

Why? Because they add another HTTP request to load a file called wp-emoji-release.min.js and that request will load on all individual pages of your site.

Disabling Emojis

You can do this in a couple of ways, using code or using a plugin.

Using a Plugin

If you choose to do it this way you can use a free plugin by the name of Disable Emojis. It is a lightweight plugin, so it won’t have too much effect and it removes the additional JS file for supporting Emojis in older browsers. Download it in the same way as you would any other WordPress plugin.

You could also use another free plugin called Emoji Settings or a premium plugin called perfmatters.

Using Code

If installing another plugin on your WordPress site doesn’t appeal to you, you can down the code route. All you need to do is edit the functions.PHP file of your theme with the following code.

NOTE – not to be done if you are not experienced. Making edits to source code can seriously mess up your website if you do it wrong!

Here’s the code:

/**
* 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;
}

It’s a bit long but it will do the job and you should find your website pages load significantly faster now.

Again, I must stress, if you are not comfortable with editing code, either go down the plugin route or let a developer do the job for you.

And don’t forget to back up your website before you do anything, just in case it does all go wrong.