By default, WordPress loads emoji scripts and styles even if you’re not using them. If you care about performance and want a cleaner front-end, you can disable them entirely with a few lines of code.
Here’s a neat snippet you can drop into your theme’s functions.php file or a custom plugin:
1
function disable_wp_emojis() {
2
remove_action('wp_head', 'print_emoji_detection_script', 7);
3
remove_action('wp_print_styles', 'print_emoji_styles');
4
remove_action('admin_print_scripts', 'print_emoji_detection_script');
5
remove_action('admin_print_styles', 'print_emoji_styles');
6
remove_filter('the_content_feed', 'wp_staticize_emoji');
7
remove_filter('comment_text_rss', 'wp_staticize_emoji');
8
remove_filter('wp_mail', 'wp_staticize_emoji_for_email');
9
add_filter('tiny_mce_plugins', 'disable_emojis_tinymce');
10
}
11
add_action('init', 'disable_wp_emojis');
12
function disable_emojis_tinymce($plugins) {
13
if (is_array($plugins)) {
14
return array_diff($plugins, array('wpemoji'));
15
}
16
return array();
17
}
Why Disable Emojis?
Here are a few reasons why developers remove WordPress emoji scripts:
- Performance boost: Reduces extra HTTP requests and unnecessary JavaScript.
- Cleaner markup: Removes injected emoji support code from the head.
- Minimal design: If you’re not using emojis, it’s just dead weight.
Safe to Use?
Absolutely! This code only removes emoji support. Native emojis (like 😊) will still display just fine on modern browsers, it just stops WordPress from loading the extra JS and CSS that simulate emoji rendering in older browsers.
Where to Add the Code
Add it to:
- Your active theme’s functions.php
- A child theme’s functions.php
- A custom functionality plugin
Before you add any code snippets to your project, make sure you understand what the code does and back up your files just in case. Even small changes can have big effects, so test everything in a safe environment first!