Remove Emoji Script from Head in WordPress 4.2+

Posted on September 4, 2015 in WordPress Category with Easy Difficulty

Along with the WordPress 4.2 updates, there was added few new things such as Emoji Icons. This new addition creates a long script and some styles inside the <head> tag of all your WordPress pages, which affects your website loading speed.

Emoji icons are a new set of emoticons used in Android OS, iOS and even others. Since everybody complains that they can't disable the Emoji icons from admin panel, here is a simple fix to remove the script with few lines of code.

The Problem

The script and the styles below should appear in every page inside the <head> tag. Please note that I deleted some portions of the code as it is too long.

<script type="text/javascript">/*<![CDATA[*/window._wpemojiSettings={"baseUrl":"http:\/\/\/images\/core\/emoji\/72x72\/","ext":".png","source":{"concatemoji":"http:\/\/\/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");...</script><style type="text/css">img.wp-smiley,img.emoji{display:inline !important;border:none !important;...}</style>

Remove Emoji Script from WordPress

To remove or disable the script completely from all your pages, find functions.php file inside your actual WordPress Theme, using FTP or WordPress Editor (located in Appearance Menu) and add the lines below:

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');

The code above hooks the functions of the Emoji script and tells WordPress to remove it from <head> before the page is loaded. You can find the main Emoji function here. Hope this helped.

Related Articles
Hint: Wrap your code syntax (html, css or others) between <pre> and </pre> tags. All comments are moderated.

3 + three =

Subscribe by E-mail

HTML-TUTS is built under the mighty WordPress platform.