This new javascript of emoji is added in WordPress 4.2 which force loading wp-emoji-release.min.js at front end. Here is how to easily remove. Instead of doing these kind of “modern development”, re-writing WordPress in Python would be a better idea for the sake of page loading speed and eating resources by PHP. They have abnormal logic (we saw on official support page’s answer by a core developer) – the javascript loads asynchronously, so it does not impact the page loading speed. Obviously, it can not happen plus why we’ll load an unwanted javascript? It also loads the uncanny style sheets. Most serious websites do not use Emoji.
Understanding How We Will Remove wp-emoji-release.min.js Loading From WordPress
Frankly, adding these 4 lines in theme or child theme’s functions.php
file will stop the stuffs to get loaded at front end, at least this works for latest Genesis Framework :
1 2 3 4 | remove_action( 'wp_head', 'print_emoji_detection_script', 7 ); // no php needed above it 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' ); // php is not closed in the last line |
those admin_print_scripts
things are for WordPress backend / admin panel. You can flush caches after adding the snippet and test on webpagetest dot org
to see if anything is loading anymore. Here is our “success story” :
---
We found another alternative difficult logical way to remove along with removal from mail function, RSS etc. :
1 2 3 4 5 6 7 8 9 10 11 12 | if (!function_exists(disable_emojis)) { function disable_emojis() { 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' ); remove_filter( 'the_content_feed', 'wp_staticize_emoji' ); remove_filter( 'comment_text_rss', 'wp_staticize_emoji' ); remove_filter( 'wp_mail', 'wp_staticize_emoji_for_email' ); } add_action( 'init', 'disable_emojis' ); } |
First snippet will work fine, we are using that.
Remove wp-emoji-release.min.js Loading From WordPress With Your Custom Plugin
You can read this article cum guide on how to create a basic plugin to add these kind snippets in one plugin instead of adding them on theme or child theme’s functions.php
file.
We have that plugin on Github Gist, it is very light. You can wget it directly in /wp-content/plugins/
directory and activate it. It is basically for our own need, so you might not need all the functions.
Conditionally Load wp-emoji-release.min.js
It is quite obvious, you might want to have these stuffs on specific posts only. At this point we are beating all other others on guide on the same topic! Everyone can remove, but if we want to load conditionally, then? First, yo should only remove the stuffs from front end :
1 2 | remove_action( 'wp_head', 'print_emoji_detection_script', 7 ); // no php needed above it remove_action( 'wp_print_styles', 'print_emoji_styles' ); // php is not closed in the last line |
Two lines chopped off. Now, you have to load these :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | <script type="text/javascript"> window._wpemojiSettings = {"baseUrl":"http://s.w.org/images/core/emoji/72x72/","ext":".png","source":{"concatemoji":"http://127.0.0.1/HRIND/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); </script> <style type="text/css"> 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; } </style> |
on specific post via Theme’s snippet or script adding function. Genesis has this function. Frankly, you can add these on the post in text mode of Editor of the post.
Tagged With wp-emoji-release min js , papers by Abhishek Ghosh , wp-emoji-release , wp-emoji-release min , window _wpemojiSettings , wp emoji release , _wpemojiSettings , remove emoji wp , how to stop wp-emoji-release min js from loading , Source: wp-includes/js/twemoji min js