Since 2015, with the version 4.2 of WordPress, emoji support has been integrated in our favorite open source CMS. However, not everyone enjoys the use of emojis, so it may be a good idea to remove it in that case and make small performance gains by removing a few requests.
Let’s see how you can do it with or without a WordPress plugins.
Designed by Ryan Hellyer, the Disable Emojis WordPress plugin is probably the easiest way to do a clean removal of the native emojis in WordPress. Although it doesn’t guarantee it, the plugin has been designed with GDPR compliance in mind by disabling the DNS prefetching of emojis within WordPress.
If you don’t want to add a dedicated plugin just to remove emjis on your WordPress website, you can also do it by using a caching plugin that provides this feature on top of others. For example, the WP Fastest Cache plugin allows you to disable emojis.
To disable WordPress emojis without a plugin, you should edit the functions.php file in your theme. You could do it from the built-in WordPress file editor, but we strongly suggest having the built-in editor deactivated for security reasons.
In the functions.php file, add the following code and save it, then test to see if the emojis are gone by checking your website’s source code.
/*
Remove all emoji related actions and filters
*/
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' );
add_filter( 'tiny_mce_plugins', 'disable_emojis_tinymce' );
add_filter( 'wp_resource_hints', 'disable_emojis_remove_dns_prefetch', 10, 2 );
}
add_action( 'init', 'disable_wp_emojis' );
/*
Filter function used to remove the tinymce emoji plugin
*/
function disable_emojis_tinymce( $plugins ) {
if ( is_array( $plugins ) ) {
return array_diff( $plugins, array( 'wpemoji' ) );
} else {
return array();
}
}
/*
Prevent emoji DNS prefetching
*/
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/2/svg/' );
$urls = array_diff( $urls, array( $emoji_svg_url ) );
}
return $urls;
}