Disable emojis
Remove the WordPress emoji script and styles from the front end, admin, feeds and emails to save a request on every page.
// Front end, embeds, feeds and emails.
remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
remove_action( 'embed_head', 'print_emoji_detection_script' );
remove_action( 'wp_enqueue_scripts', 'wp_enqueue_emoji_styles' );
remove_action( 'enqueue_embed_scripts', 'wp_enqueue_emoji_styles' );
remove_action( 'wp_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' );
// Admin area. These hooks are added after plugins load, so remove them later.
add_action(
'admin_init',
function () {
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
remove_action( 'admin_enqueue_scripts', 'wp_enqueue_emoji_styles' );
remove_action( 'admin_print_styles', 'print_emoji_styles' );
}
);
// Classic editor (TinyMCE).
add_filter(
'tiny_mce_plugins',
function ( $plugins ) {
return is_array( $plugins ) ? array_diff( $plugins, array( 'wpemoji' ) ) : $plugins;
}
);
What it does
WordPress adds a small script and some CSS to every page so emojis look the same in old browsers. Modern browsers and phones show emojis on their own, so for most sites it's dead weight.
This snippet removes the emoji script and styles from the front end, the admin area and embeds, stops emojis in feeds and emails being turned into images, and removes the emoji plugin from the classic editor.
Good to know
- Emojis still show. Browsers draw them with the device's own emoji font.
- Some themes already remove the emoji script. Adding this snippet as well does no harm.