How to disable WordPress emojis illustration

We can make many network performance optimizations and adjustments to make WordPress sites load faster. One of the simple optimizations is to disable the loading of emoji Emojis. Emoji (Emojis) are small icons used to express thoughts or feelings. Although these icons are interesting, are they really necessary for WordPress sites? For many sites, maybe these just add unnecessary extra load time.

when WordPress 4.2 was released, support for emoticons was added to the older version of the browser WordPress core. The biggest problem is that it generates an additional HTTP request on the WordPress Web site to load the wp-emoji-release.min.js file. This file is loaded on each page, and although it is only 10. 5 KB, similar things add up over time.

How to disable WordPress emojis illustration1

Emojis emoji JS file

has two different ways to disable WordPress emoji Emojis: use free plug-ins or code to do so.

  • uses the plug-in to disable Emojis
  • modification code to disable the Emojis

1. Using plug-ins to disable Emojis

the first way to disable emoji Emojis is to simply use a free plug-in called Disable Emojis developed by Ryan Hellyer.

How to disable WordPress emojis illustration2

Disable Emojis plug-in

this is an ultra-lightweight plug-in, only 9 KB to be exact. The plug-in currently has more than 70000 activation installations and 100% praise for 5 stars. Note: Emoticons and emojis can still be used in browsers that support them built-in. The plug-in only removes redundant JavaScript files that are used to add support for emoticons in older browsers.

also has a free replacement plug-in called Emoji settings. This is developed with multiple sites in mind and provides users with the option to disable emoticons themselves.

How to disable WordPress emojis illustration3

Emoji settings plug-in

when the plug-in is enabled, users can select or uncheck “Enable emoji support” in the “Settings-compose” section of the WordPress dashboard.

you can also use the advanced plug-in of the perfmatters class, which supports disabling emoji emoticons and other optimizations for WordPress sites.

How to disable WordPress emojis illustration4

uses the plug-in perfmatters to disable emojis

two。 Modify the code to disable Emojis

if you do not want to install various plug-ins, you can also use the code to disable emoticons. Simply add the following to the functions.php file of the WordPress theme. This is essentially the code for the Disable Emoji plug-in.

warning: please prepare a copy of the source file before modifying the code, so as not to cause problems with the website due to improper operation, you can restore it through backup!
/**
 * 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 betwen 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/svg/' );

$urls = array_diff( $urls, array( $emoji_svg_url ) );
 }

return $urls;
}
Disclaimer: All articles on this website, unless otherwise specified or marked, are original and published on this website. Any individual or organization is prohibited from copying, stealing, collecting, or publishing the content of this site to any website, book, or other media platform without the consent of this site. If the content on this website infringes on the legitimate rights and interests of the original author, you can contact us for assistance.