Disable Emoji in WordPress Using a Plugin or Adding PHP Codes

Like it or not, emoji has become an indispensable part of internet communications. Originally started as pictograms in the early 1980s, emoji gained popularity in the late 1990s through the use of the mobile email service in Japan. Since then, emoji gained widespread acceptance and used everywhere, from forum posts to social media statuses. Currently, emoji have even been standardized and contain a wide set of reaction image, from cute to outright horrible.

However, not every situation calls for emoji. Emoji is still shunned informal communication, for example, and likely the situation will not change any time soon. If you are working with a corporate website, for example, you might want to avoid using emoji on your website, whether it is intentional or not. Some mathematical equations might also be parsed as emoji, which might cause problems in e-learning websites.

If you use WordPress as your website development platform, you might be aware that WordPress includes emoji parser by default. The emoji parser in WordPress can also convert adjacent symbols/emoticons into emoji. This will not be a problem for most websites, but as aforementioned before, corporate or education websites might have a problem with emoji.

Emoji could also introduce parsing error in your WordPress website, resulting in boxes instead of intended emoji if the browser is incapable of rendering the emoji. The WordPress emoji library, wp-emoji-release.min.js, while only around 10kB in size, is also required in every page load, resulting in sluggishness in certain pages especially in bandwidth-limited situations.

Fortunately, like most things related to WordPress, you can disable emoji by installing a plugin or modifying the code directly. To start, find out first whether your WordPress installation calls for the emoji library. You can observe this behavior by visiting webpagetest.org and entering your website address. 

If emoji is enabled in your WordPress site, you will see an extra HTTP request pointing to wp-emoji-release.min.js in the waterfall view. Then, you can choose to install a plugin or modifying the WordPress code directly to stop wp-emoji-release.min.js from loading.

Disable Emoji in WordPress Using a Plugin

Installing a plugin is easier and most recommended if you are new to WordPress development. To install a plugin which will block emojis, head to the administration panel of your WordPress installation, and click Plugins > Add new. Enter “Disable Emojis (GDPR friendly)” to the search bar, click “Install now” button and let the installation process do its thing.

Disable WordPress emoji using a plugin
Disable WordPress emoji using a plugin

Afterward, click the “Activate” button beside the plugin name, and voila! No more emojis in your WordPress installation.

PS. You can also try to download the plugin directly from https://wordpress.org/plugins/disable-emojis/ and then upload the plugin .zip file from Plugins > Add New > Upload Plugin.

To verify, you can visit webpagetest.org. You should see that the request to wp-emoji-release.min.js has been removed.

Disable Emoji in WordPress Using PHP Codes

Another option to disable emoji in your WordPress website is by modifying the underlying WordPress code. However, be aware that you might break some functionality if you are not careful. 

Always back up your WordPress core files before editing them so that you can restore from the backup if something happens. To start modifying the WordPress code, first of all, you need to disable “Convert emoticons to graphics on display” in the Writing settings page. After disabling the option, open your favorite FTP client (we recommend FileZilla as it is open source and compatible with Windows, Mac, and Linux), and connect to your site through FTP. 

Open the folder wp-content/themes/your-active-theme/ and download functions.php from the folder. Then, open the file using your text editor and copy these codes:

/* Disable the emojis */
function risbl_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' );
	
	// Remove from TinyMCE
	add_filter( 'tiny_mce_plugins', 'risble_disable_emojis_tinymce' );

	// Remove DNS prefetch
    add_filter( 'wp_resource_hints', 'risbl_remove_emoji_dns_prefetch', 10, 2 );
}
add_action( 'init', 'risbl_disable_emojis' );

/* Remove emoji DNS prefetch */
function risbl_remove_emoji_dns_prefetch( $urls, $relation_type ) {
    if ( 'dns-prefetch' == $relation_type ) {
        $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;
}

/* Remove emoji from TinyMCE */
function risble_disable_emojis_tinymce( $plugins ) {
	if ( is_array( $plugins ) ) {
		return array_diff( $plugins, array( 'wpemoji' ) );
	} else {
		return array();
	}
}

After editing the file, open up your FTP client again, and this time, upload the edited file and replace the file already existing in the server. Accept the warning and the file will start uploading. Then, open webpagetest.org to verify if the code worked and you have disabled emoji from your WordPress installation. Good luck!

Leave a Comment

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