Disabling WordPress Emoji Script
Custom Code Solution
Add this code to your theme's functions.php
file or in a site-specific plugin:
This code removes the WordPress emoji script and related resources to improve page load time:
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 the TinyMCE emojis
add_filter('tiny_mce_plugins', 'disable_emojis_tinymce');
// Remove emoji CDN hostname from DNS prefetching hints
add_filter('wp_resource_hints', 'disable_emojis_remove_dns_prefetch', 10, 2);
}
add_action('init', 'disable_wp_emojis');
function disable_emojis_tinymce($plugins) {
if (is_array($plugins)) {
return array_diff($plugins, array('wpemoji'));
}
return array();
}
function disable_emojis_remove_dns_prefetch($urls, $relation_type) {
if ('dns-prefetch' === $relation_type) {
$emoji_svg_url = apply_filters('emoji_svg_url', 'https://s.w.org/images/core/emoji/');
$urls = array_diff($urls, array($emoji_svg_url));
}
return $urls;
}
Plugin Solutions
If you prefer using a plugin, here are reliable options:
-
Disable Emojis - Simple, lightweight plugin that only removes emoji functionality
-
Asset CleanUp - More advanced plugin that can disable emojis along with other WordPress scripts and styles
Benefits
- Reduces HTTP requests
- Decreases page load time
- Removes unnecessary JavaScript
- Cleans up your site's HTML output
Important Notes
- This won't affect emoji display in modern browsers as they handle emoji rendering natively
- The code removes both front-end and admin emoji scripts
- Compatible with all major WordPress versions
- Works with both classic editor and Gutenberg
If you only want to disable emojis on the frontend while keeping them in the admin area, modify the code to remove the admin-related hooks.