Emoji or Emoticon or smiley is a digital pictorial icon used to convey emotions. Emojis were first introduced in WordPress 4.2. This post describes about the ways to remove wp-emoji-release.min.js JavaScript code from WordPress.
I scanned a website for malware detection. Quttera online website scanner shows there are around 40 files are suspicious. Quttera displays most of the index.html and other HTML's contain suspicious code inside wp-emoji-release.min.js, but there is no such malicious content present inside wp-emoji-release.min.js. Quttera itself adds wp-emoji-release.min.js in suspicious category. Emoji in WordPress is rarely used. So I decided to remove the wp-emoji-release.min.js from WordPress.
wp-emoji-release.min.js is found in head section of the theme like
WordPress in Emoji can be removed through either code or plugin. In this article both ways are explained.
Emoji in WordPress not just found in one place. Emoji is added to head section of WordPress theme, added to admin section, RSS feeds, emails, Resource Hints and TinyMCE Editor. Both Emoji Script and its associated CSS style sheets has to be removed.
Removing emoji js from WordPress also increases the site speed performance. Adding too many script to the website decreases the loading time. To optimize site speed it is better to remove unwanted scripts. Google weighs site speed as one of the SEO factor to list the website in first page of the google search results.
Remove Emoji js using PHP code
Following code is used to disable or remove the emoji javascript code from WordPress
PHP Code
//* Disable the emoji's
function disable_emojis() {
//* Remove Emoji from head section and css
remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
remove_action( 'wp_print_styles', 'print_emoji_styles' );
//* Remove Emoji from admin section and css
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
remove_action( 'admin_print_styles', 'print_emoji_styles' );
//* Remove Emoji from RSS feed
remove_filter( 'the_content_feed', 'wp_staticize_emoji' );
remove_filter( 'comment_text_rss', 'wp_staticize_emoji' );
//* Remove Emoji from emails
remove_filter( 'wp_mail', 'wp_staticize_emoji_for_email' );
//* Remove Emoji from TinyMCE Editor
add_filter( 'tiny_mce_plugins', 'disable_emojis_tinymce' );
//* Remove Emoji from Resource Hints
add_filter( 'wp_resource_hints', 'disable_emojis_remove_dns_prefetch', 10, 2 );
}
add_action( 'init', 'disable_emojis' );
//* Function to remove the TinyMCE emoji plugin.
function disable_emojis_tinymce( $plugins ) {
if ( is_array( $plugins ) ) {
return array_diff( $plugins, array( 'wpemoji' ) );
} else {
return array();
}
}
Add this code to the end of the functions.php in WordPress parent theme.
Disable Emoji using Plugins
Plugins are available in WordPress to enable or disable Emojis. Here some of the available plugins are listed,
Disable Emojis (GDPR friendly)
WP Disable Emoji
Disable WP Emojis
Really Disable Emojis
Disable WP Emoji Icons
Emoji Settings
WP Head Optimizer
This plugins are available in WordPress Plugins repository. Install and activate the required plugin based on its popularity and compatible with your WordPress version. Use this plugins if you are not comfortable with the code.