Remove Emoji Script from Head in WordPress 4.2+

Posted on September 4, 2015 by Dan Doicaru 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:\/\/s.w.org\/images\/core\/emoji\/72x72\/","ext":".png","source":{"concatemoji":"http:\/\/site.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");...</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 EMOJI SCRIPT FROM HEAD TAG IN WORDPRESS
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.

Rate & Share
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Related Articles
Comments
Hint: Wrap your code syntax (html, css or others) between <pre> and </pre> tags. All comments are moderated.


+ 6 = 8

Search
Subscribe by E-mail

HTML-TUTS is created and maintained by Dan Doicaru.
This website is a rebrand to Extreme Design Studio (extremestudio.ro), built under WordPress platform.