WordPress
81 views

How to Disable Emojis in WordPress

How to Disable Emojis in WordPress

If you’re looking to optimize your WordPress website for performance and remove unnecessary scripts, disabling emojis is a good practice. Emojis may add some visual appeal, but they can also contribute to increased page load times. In this article, we’ll guide you through the process of disabling emojis in WordPress.

What Does the Code Do?

The provided code is a set of functions in PHP that, when added to your WordPress theme’s functions.php file, disables the emoji scripts and styles from being enqueued. This helps in preventing the loading of emoji-related files, improving the overall performance of your WordPress site.


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 Install:

  1. Open your WordPress theme’s functions.php file in a code editor.
  2. Copy and paste the provided code at the end of the file.
  3. Save the changes.

That’s it! You’ve successfully disabled emojis on your WordPress site, improving its performance by reducing unnecessary script and style loads.

Remember to test your site to ensure that emojis are no longer being loaded, and your website’s performance has improved.

How useful was this post?

Click on a star to rate it!

Average rating 5 / 5. Vote count: 1

No votes so far! Be the first to rate this post.

As you found this post useful...

Follow us on social media!

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?

Tags: Emoji Removal, Functions.php Configuration, PHP Functions, WordPress Optimization, WordPress Performance
You must be logged in to post a comment.