Disable 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 files to improve page load times:
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_wp_emojis_tinymce');
// Remove emoji DNS prefetch
add_filter('emoji_svg_url', '__return_false');
}
add_action('init', 'disable_wp_emojis');
function disable_wp_emojis_tinymce($plugins) {
if (is_array($plugins)) {
return array_diff($plugins, array('wpemoji'));
}
return array();
}
What This Code Does
- Removes emoji detection script 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 - Simple plugin that only removes emojis
-
Asset CleanUp - More features including emoji removal and other performance optimizations
Additional Notes
- This code is safe to use and won't affect regular text emoticons like :) or ;)
- Users can still copy/paste emoji from other sources
- The code maintains compatibility with existing content
After implementing either solution, clear your site's cache and CDN cache (if applicable) to see the changes take effect.