Search
Close this search box.

How to Disable Emojis in WordPress (Without Plugin)

Emoji support is added to the core of WordPress since they released WordPress 4.2. Emoji support can be quite a useful feature if you want to decorate your content with emojis. However, if you have no use for emoji support, you may want to disable it to improve your website performance.

Disabling emojis is one of the small optimizations that may help you on improving your website load time. Since disabling emoji can stop the HTTP requests to the wp-emoji-release.min.js file that generates every time you load a page on your entire website.

In this tutorial, we will show you how to disable emojis in WordPress by using a custom code.

Disable Emoji Support in WordPress

Before you get started, you may want to backup your site and use a child theme to avoid breaking the parent theme or losing your changes when you update your theme.

Once ready, go to Appearance -> Theme File Editor from your WordPress admin dashboard, then click the functions.php file from the Theme Files panel to open the file editor.

Once you have opened up the file, add the following custom code to the editor. You can place the code anywhere under the <?php tag and outside of any existing function in the file.

/**
 * 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;
}

Once the code is in place, save your changes by clicking on the Update File button.

Bottom Line

No optimization is ever too small in improving your website performance. Disabling emojis is one of the small optimizations that may help you on improving your website load time. And we already wrote about another WordPress optimization by disabling the embeds feature before. By doing these little tricks and optimization, you can start shaving off your website’s overall load time over time.

This page may contain affiliate links, which help support our project. Read our affiliate disclosure.
Picture of Hendri Risman

Hendri Risman

Hendri is a WordPress expert and a writer staff at WPPagebuilders. He writes solutions on how to get things fixed in WordPress a lot. Mostly without involving a plugin.
Want to turn your WordPress knowledge into revenue? OF COURSE!

1 thought on “How to Disable Emojis in WordPress (Without Plugin)”

Leave a Comment

Share This
Hey 👋🏻
Do you have a WP blog?
If so, you may need these. All the resources you need to grow your blog.

Your popup content goes here

50%

Where should we send the template?

After entering your email address, you will be added to our newsletter subscribers. You can unsubscribe anytime.

Want to Build Passive Income Like the One on the Screenshot Below?

Click the button on the right side to learn how 👉🏻
5 easy steps to turn your WordPress knowledge into monthly recurring revenue.

Click the above button to close the popup.