30Apr

Remove WordPress emoji code in your pages head without plugin

Here is a quick tip to remove the piece of code added by WordPress 4.2 in the header of your pages about emoji icons

That’s the code WordPress adds in your page:

window._wpemojiSettings = {"baseUrl":"http:\/\/s.w.org\/images\/core\/emoji\/72x72\/","ext":".png","source":{"concatemoji":"http:\/\/your-url\/wp-includes\/js\/wp-emoji-release.min.js?ver=4.2.1"}};
    !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);
 
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;
}

 

How to remove the WordPress emoji code

In functions.php (your WordPress theme)
Add the following lines

// REMOVE WP EMOJI
remove_action('wp_head', 'print_emoji_detection_script', 7);
remove_action('wp_print_styles', 'print_emoji_styles');

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

Easy!

Subscribe
Notify of
43 Comments
Oldest
Newest
Inline Feedbacks
View all comments
5 years ago

Yeah, the source code is pretty horrible. I was a little surprised when I saw it appear in my source. Thankfully it wasn’t too hard to get rid of.

5 years ago

Thank you very much. Really a very simple solution to turn off Emoji without plugin

Colin
5 years ago

You might be interested, there is an extra couple of lines of code that removes everything. https://www.searchcandy.uk/blog/wordpress/how-to-disable-emojis-in-wordpress/

5 years ago

For those who find this. Here is a quick tut on how to create a plugin to remove the emojis.

http://www.jaxbeachwebsites.com/write-plugin-remove-wordpress-emoji-code/

5 years ago

awesome Function…. for removing emojii..

5 years ago

really simple code, but is working for me… thank bro

[…] une astuce trouvée sur le site denisbouquet.com et qui fonctionne parfaitement permettant de supprimer sans plugin les emojis […]

4 years ago

really simple code, but is working for me

4 years ago

At least a nice code and really simple for emoji. Used for a back button with special char… Thanks

4 years ago

The less plugins the better, so I’m glad you shared this option.
Worked perfectly, Thanks

Thanks !!!

4 years ago

Nice. It´s work.

feb
4 years ago

Works :) Thank you!

Steele
4 years ago

Great!! Thank you!!

4 years ago

The only solution that worked for me, thank you!

3 years ago

Thanks so much for this nice and simple code, very useful!

3 years ago

Excellent Functions. Thanks for your shared.

Sapna Rajput
3 years ago

Thankyou!

Giasar Ali Oglou
3 years ago

I NEED HELP! The Code just poped up on my side and didnt do nothing!…. Now i get this Code (after removing the code): functions.php on line 402

3 years ago

Simple and effective!

3 years ago

Thank you, that was easy and fast.

oyeguest
3 years ago

Thanks.

It worked. I checked through waterfall available in gtmetrix.

3 years ago

Much appreciation for sharing!

3 years ago

Works with update 4.7.5. Thank you so much!

3 years ago

Wow thanks! very easy!

3 years ago

Thank you!

Kirston
2 years ago

Hi Denis well I found a plugin got no settings, isn’t it fast too?

https://wordpress.org/plugins/disable-emojis-littlebizzy/

2 years ago

working for me, thanks

2 years ago

WORK ! very good ,Thanks

2 years ago

March 2018, still works. Many thanks.

2 years ago

Thank you very much, works perfectly.

Marita Schou Johanson
2 years ago

Thank you.

[…] Пишуть люди […]

Tyler
2 years ago

YES!!

2 years ago

Thanks for providing this. I used the code but am still having some other errors which might not be related. Trying to remove Coinhive malware which I thought this emoji script might have been allowing.

1 year ago

Thanks denis. just implemented it on my website.

1 year ago

Awesome!

cleuenberg
1 year ago

Hi Denis, thanks for the article! Although this is about removing the emojis without a plugin, I would like to suggest a plugin solution with “Really Disable Emojis” (https://wordpress.org/plugins/really-disable-emojis/) which is pretty lightweight. Just needs to be installed and activated in order to work. I use this on several client’s websites now.

5 months ago

Still beautiful in 2020!