WordPress performance

Improve WordPress performance and Stop loading default emoji in WordPress.

by Arif Uzzaman in Plugin on October 18, 2020

Improve WordPress performance and Stop loading default emoji in WordPress

There are many issues with improving WordPress performance that you can fix to make your website load faster. We all want to increase the speed of our website. So that people can quickly access and browse the website. And if we want to speed up the website, we have to look at kilobytes, every byte. By reducing the size by byte, you can see that the size of the website has decreased a lot and it is loading very fast.

One of the simplest optimizations of emoji icons is to stop loading emoji files. Emoji are just some of the little cartoon icons that we use to express our tone, expression, attitude, etc. These are actually quite funny, many of us use these emojis on Facebook. But you think, do you really need these on your website? If you take the website seriously then you will surely find unnecessary loading of 10 kilobytes unnecessary.

Emoji has been added since version 4.2 of WordPress to support emoji in older browsers. The biggest problem is that it creates an additional HTTP request when your website loads. Although your website does not require emoji, the wp-emoji-release.min.js file loads when it is loaded. The bigger problem is that it loads on every page of your website. You may have noticed a common problem in GT Metrix is ​​that Make Fewer HTTP Request. You can reduce an HTTP request by just adding a little code of four lines if you want.

Add the following code to the functions.php file of your WordPress website. Of course, from now on, the emoji script and its CSS will no longer load.

// Remove WP Emojis
remove_action(‘wp_head’, ‘print_emoji_detection_script’, 7);
remove_action(‘wp_print_styles’, ‘print_emoji_styles’);
remove_action( ‘admin_print_scripts’, ‘print_emoji_detection_script’ );
remove_action( ‘admin_print_styles’, ‘print_emoji_styles’ );

The above code will work, or you can add these codes if you want to use a little more detail code for more improving WordPress performance.

/** * Disable the emoji’s */
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’ );
/**
* Filter function used to remove the tinymce emoji plugin.*
* @param array $plugins
* @return array Difference betwen the two arrays
*/
function disable_emojis_tinymce( $plugins ) {
if ( is_array( $plugins ) ) {
return array_diff( $plugins, array( ‘wpemoji’ ) );
} else {
return array(); } }
/**
* Remove emoji CDN hostname from DNS prefetching hints. *
* @param array $urls URLs to print for resource hints.
* @param string $relation_type The relation type the URLs are printed for.
* @return array Difference between the two arrays.
*/
function disable_emojis_remove_dns_prefetch( $urls, $relation_type ) {
if ( ‘dns-prefetch’ == $relation_type ) {
/** This filter is documented in wp-includes/formatting.php */
$emoji_svg_url = apply_filters( ’emoji_svg_url’, ‘https://s.w.org/images/core/emoji/2.3/svg/’ );
$urls = array_diff( $urls, array( $emoji_svg_url ) );} return $urls; }

Or you can solve this problem with plugins if you think it’s a problem. That’s why you can use the Disable Emojis plugin. You can also use this plugin to improve the wordpress speed optimization of your WordPress website.

Hello Hello Hello If you are looking for WordPress Article?

Many thanks to everyone for reading so hard.