Menu

How to disable emoji scripts from your WordPress site

If you run your own WordPress site, you may have noticed that one of the things that gets injected into the <HEAD> section of each page is support for emojis.

Emoji support has been baked into WordPress since version 4.2 so scripts are added to your site whether or not you want them.

If you view the source of any of your site’s pages, you’ll see the JS and CSS that gets injected:

wordpress emoji scripts head
Is there an emoji for “Oh, for f**k’s sake already!”?

The problem here, for me anyway, is that I have no need for emoji support on my site. Besides, many browsers already include emoji support.

The main issue is I only want my site to use only what it needs. Anything that can contribute to optimal performance is a good thing!

The solution

To disable these pesky whippersnappers, copy and paste the following into your theme’s functions.php file:

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

Save and reload your site.

You should no longer see the emoji scripts in your <HEAD> section.

Does disabling emoji scripts actually improve performance?

If page loading times are a priority (and they are, right?), then we should check to see what gains we can make, if any, by disabling the emoji scripts from loading.

I ran a speed test both with and without emoji scripts enabled and it appears that disabling them seems to make a difference:

wp disabled emoji performance test results

To be fair, a number of things can affect a page speed test so I’m not overly-excited at scoring 100 (although it is nice), since any other number of factors can be the cause of that extra point gain.

The total number aside, a gain of one point may be a gain but it isn’t anything to cheer over.

There also isn’t a score above 100 so for all I know, if in fact this change made the difference, it’s more than one point.

Not to mention that speed test results can fluctuate by many percentage points even with back to back tests.

But in this case, yeah, I’ll take it.

Have fun!

Archived under:
Share:
This site uses cookies to collect basic info to help improve your experience. Read my Privacy Policy Accept