How to Remove or Disable Extra JS included in WordPress 4.2 for Emoji Support?

The Emojis are cool, loved and used by many WordPress authors. But there are few, like me, who don’t use Emojis. Starting from version 4.2, WordPress supports Emoji’s by default. It means, an extra Javascript file gets added to your site’s header to support 4 bit unicode characters. Interestingly, the feature will support Japanese, Chinese and Korean character sets in WordPress. That’s a cool one and our kudos to WordPress team. But you know something, I just updated WordPress to version 4.2, but didn’t opt to use Emoji. Also, WordPress does not have an option to disable Emojis. If you are someone looking to remove or disable Emoji support on WordPress 4.2, then here’s how you can do that.

As the title says, we are going to remove that extra script included in latest version of WordPress. It means, you are good to use age old smileys  ( 🙂 ) that should still be supported by modern browsers. But you will not have privilege to use advanced Emojis.

Download eBook on WordPress Optimization

emoji support wordpress

This is what you will see in HTML source (included by default after upgrading WordPress to version 4.2)

<script type="text/javascript">
window._wpemojiSettings = {"baseUrl":"http:\/\/s.w.org\/images\/core\/emoji\/72x72\/","ext":".png","source":{"concatemoji":"http:\/\/www.website.com\/wp-includes\/js\/wp-emoji-release.min.js"}};
!function(a,b,c){function d(a){var c=b.createElement("canvas"),d=c.getContext&&c.getContext("2d");return d&&d.fillText?(d.textBaseline="top",d.font="600 32px Arial","flag"===a?(d.fillText(String.fromCharCode(55356,56812,55356,56807),0,0),c.toDataURL().length>3e3):(d.fillText(String.fromCharCode(55357,56835),0,0),0!==d.getImageData(16,16,1,1).data[0])):!1}function e(a){var c=b.createElement("script");c.src=a,c.type="text/javascript",b.getElementsByTagName("head")[0].appendChild(c)}var f;c.supports={simple:d("simple"),flag:d("flag")},c.supports.simple&&c.supports.flag||(f=c.source||{},f.concatemoji?e(f.concatemoji):f.wpemoji&&f.twemoji&&(e(f.twemoji),e(f.wpemoji)))}(window,document,window._wpemojiSettings);
</script>
<style type="text/css">
img.wp-smiley,
img.emoji {
	display: inline !important;
	border: none !important;
	box-shadow: none !important;
	height: 1em !important;
	width: 1em !important;
	margin: 0 .07em !important;
	vertical-align: -0.1em !important;
	background: none !important;
	padding: 0 !important;
}
</style>

and here’s how you can remove it.

Add remove action to disable Emoji in WordPress

Copy the below code and add it to your theme’s functions.php file.

remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
remove_action( 'wp_print_styles', 'print_emoji_styles' );

To disable Emoji on WordPress Admin pages

remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
remove_action( 'admin_print_styles', 'print_emoji_styles' );

That’s it!

Updated on September 2, 2017

Was this article helpful?

Related Articles

Leave a Comment