How to disable Emojis script in WordPress

How to disable Emojis script in WordPress

In this article, I will show you how to disable Emojis in WordPress easily and Improve your Blog Loading speed.

WordPress by default Loads the emojis scripts and stylesheets to show emojis on the website. But, as you know you can easily block the loading of this script and still show the default Browser emojis to the users. In this way, You can reduce the total number of requests and the size of the webpage.

As you may know core web vitals is now a ranking factor for your website. So you should remove all those unnecessary scripts from loading on your website which ultimately reduces your website speed. There are many ways which you can use to block the loading of Emojis script on WordPress. Either you can use any custom PHP code snippets or you can use perfmatters plugin for that.

How to Disable Emojis in WordPress without a plugin?

First, check if you can disable emojis on WordPress without a plugin. To block the wordpress emojis you need to paste the below code in the functions.php file of your theme or you can use any code manager plugin to paste the code as well.

function disable_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_emojis' );
 
function disable_emojis_tinymce( $plugins ) {
 if ( is_array( $plugins ) ) {
 return array_diff( $plugins, array( 'wpemoji' ) );
 } else {
 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/2/svg/' );
 
$urls = array_diff( $urls, array( $emoji_svg_url ) );
 }
 
return $urls;
}

How to disable Emojis in WordPress using the Litespeed cache plugin?

If you are using LiteSpeed cache plugin on your website, you can disable Emojis scripts in WordPress with a single toggle switch. Just Go to the Litespeed Cache optimization option and under that click on the HTML settings.

Here, scroll down and look for “ Remove WordPress Emoji “ option. Just enable that option and click on save changes.

How to disable Emojis in WordPress using the Litespeed cache plugin?

Now you have successfully disabled the WordPress Emojis scripts from loading on your website.

How to disable Emojis in WordPress using the Perfmatters plugin?

By using the Perfmatters plugin then you can disable emojis scripts in WordPress with just one click. All you need to do is, when you open the perfmatters settings page, you will see the option at the very beginning “Disable Emojis”.’

How to disable Emojis in WordPress using the Perfmatters plugin?

Just Enable the settings and you are good to go. Emojis will be disabled from your wordpress website.

Conclusion

In this Article, You have learned how to disable Emojis on your WordPress site. If you still have any questions regarding this, feel free drop your query in the comment section.