Removing emoji code added to the head in WordPress

03 May, 2015 by Tom Elliott

You might have noticed that the latest release of WordPress (version 4.2) has added a few lines of CSS and JavaScript code to the head element to each page on your site due to expanding support for the display of emoji

This emoji code will look something like the below

<script type="text/javascript">
window._wpemojiSettings = {"baseUrl":"","ext":".png","source":{"concatemoji":""}};
			!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);
<style type="text/css">
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;

To disable this emoji support and prevent the code above being displaying on your site, add the below two lines in your functions.php file.

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

The extra lines of in-line code WordPress adds for emoticon support probably won’t cause any issues for your site and the extra bytes won’t have a noticeable impact on page load times but for someone like myself who is frequently working with WordPress, I like to keep my code looking as clean and clutter free.

Many of the WordPress sites I work on are more corporate, so emoji support for either blog posts or commenting isn’t relevant.


  • Ben says:

    Thanks for this. For some reason the extra code seemed to be screwing up an image gallery I had running. Adding those lines to the functions.php file worked so well!


  • Kevin says:

    Just added this and it caused an error, removed it and its taken the entire site down!

    Despite adding it in the child theme functions.php and then removing this file entirely the site is dead WTF?

    • Tom Elliott says:

      Hi Kevin, sorry to hear about your problem. I’ve added this code to many websites on different servers without a hitch. My first thought, if you can’t undo the changes would be to rename or delete functions.php (especially if using the WordPress editor) but like you said you’ve tried that. Happy to take a look if you’re still having issues.

  • Andersson says:

    Works for me! Thanks!

  • Hayden James says:

    Does it matter where within the functions.php file its located?

  • Thanks for this đŸ™‚

  • Aan says:

    really simple code, but is working for me… thank you very much

  • Richard says:

    Thanks for this fix! has been causing me issues with my load time in Gt Metrix

  • Matt says:

    I’m seeing a bunch of other remove actions that target WP emojis. Any idea what the rest of these are?:

    function disable_wp_emojicons() {

    // all actions related to emojis
    remove_action( ‘admin_print_styles’, ‘print_emoji_styles’ );
    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_filter( ‘wp_mail’, ‘wp_staticize_emoji_for_email’ );
    remove_filter( ‘the_content_feed’, ‘wp_staticize_emoji’ );
    remove_filter( ‘comment_text_rss’, ‘wp_staticize_emoji’ );

    // filter to remove TinyMCE emojis
    add_filter( ‘tiny_mce_plugins’, ‘disable_emojicons_tinymce’ );
    add_action( ‘init’, ‘disable_wp_emojicons’ );