Solution to Disable WordPress Emoji Scripts
Here's a simple code snippet that removes WordPress emoji scripts and related code from your site:
Add this code to your theme's functions.php
file or in a site-specific plugin:
function disable_wp_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');
// Remove TinyMCE emojis
add_filter('tiny_mce_plugins', 'disable_emojis_tinymce');
// Remove emoji DNS prefetch
add_filter('emoji_svg_url', '__return_false');
}
add_action('init', 'disable_wp_emojis');
function disable_emojis_tinymce($plugins) {
if (is_array($plugins)) {
return array_diff($plugins, array('wpemoji'));
}
return array();
}
This code:
- Removes emoji detection scripts from front-end and admin
- Removes emoji styles
- Removes emoji from RSS feeds
- Removes emoji from emails
- Disables emoji in TinyMCE editor
- Removes emoji DNS prefetch
Plugin Alternative
If you prefer using a plugin, here are reliable options:
-
Disable Emojis - A lightweight plugin specifically designed for this purpose
-
Asset CleanUp - A more feature-rich plugin that can disable emojis along with other optimizations
Impact
Disabling emojis can:
- Reduce HTTP requests
- Remove unnecessary JavaScript
- Slightly improve page load time
- Clean up your site's header
The code solution is preferred as it's lighter than installing a plugin for this single purpose.