Dotlayer
  • News
  • Startups
  • Tutorials
  • SEO
  • Marketing
  • Interviews
No Result
View All Result
Dotlayer
  • News
  • Startups
  • Tutorials
  • SEO
  • Marketing
  • Interviews
No Result
View All Result
Dotlayer
No Result
View All Result

How to Speed Up Your WordPress Site By Disabling Smileys, Emojis and Emoticons

July 27, 2017
in Tutorials
0 0
Share on FacebookShare on Twitter

WordPress has been constantly improving with new and exciting features in each new edition. Some of these new features range from something really small to very substantials updates. Starting from version 4.2, for example, WordPress added support for new Emojis. In general emojis and smiley allow you write more fun posts.

The thing is, on the web, Emojis are essentially just a set of javascript and images files. The files that contain these add multiple requests to your WordPress site. It’s all fun and games until your site starts loading slowly.

We at WPLobster.com are strong believers in Web Performance and are fully convinced that if you don’t need a resource on the website, it should be taken away. Ilya Grigorik, web performance engineer at Google; co-chair of W3C Webperf WG, once said that

No bit is faster than one that is not sent; send fewer bits.

As Ilya says, the fastest and easiest way to improves the speed of your website is to send as little data over the wire as possible. You don’t want your website to load files that you might not be using.

For WordPress to display an Emoji, WordPress loads a script with the file name wp-emoji-release.min.js, as part of the requests. That is the script that we are going to try to prevent from loading on the web page when it loads. Below is a screenshot of the script loading on a website that doesn’t have disabled.

Approach #1: Using WordPress Hook in the functions.php

If you don’t want to install another plugin, you can also just disable emojis with code. Simply add the following to your WordPress Theme’s functions.php file. If you don’t know what function.php is, it’s one of the core functions of your theme and the code in there executes on every request. It’s a very useful place to put code that needs to fun at any time.

/**
* Disable the emoji's
*/
function disable_wordpress_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_wordpress_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;
}

Approach #2: Using A WordPress Plugin

If for some reason you are not able to make changes to the functions.php file of your theme, there is another alternative. There are a collection of plugins in the WordPress plugin repository that can allow you to do that without touch any piece of code.

The plugins essentially perform the same function, and most of them contain the exact same code as described above. While we tend to discourage the use of plugins for such small changes, we totally understand and have seen scenarios where it’s impossible to make the change in the function.php file.

There are 3 major plugins that allow you to do this effectively.

Disable Emojis

Disable WP Emojis

Disable Emojis

Just like all other plugins, you just need to download them, install it and then activate it. You will be able to see it in your admin/settings page.

We hope you learnt something new from this post. Feel free to reach out to one of our experts to talk about the best ways we can help you speed up your website and troubleshoot any website issues you might be facing. If you enjoyed reading this article or it was a helpful resource, then please share it or leave a comment below and let us know what you think.

ShareTweetPin
Previous Post

Top 20 Best Tattoo, Face Painting, Body Painting & Body Piercing Parlor WordPress Themes 2017

Next Post

Your Definitive Guide to the Best WordPress Hosting Services – The 100 Best WordPress Hosting Services Reviewed

Next Post

Your Definitive Guide to the Best WordPress Hosting Services - The 100 Best WordPress Hosting Services Reviewed

You might also like

Calendarific Unveils New Pricing Plans

Calendarific Unveils New Pricing Plans

July 27, 2023
CurrencyBeacon vs. Currency Freaks, Fixer.io, and OpenExchangeRates: Which API is Best?

CurrencyBeacon vs. Currency Freaks, Fixer.io, and OpenExchangeRates: Which API is Best?

June 17, 2023
Mint Linux vs Ubuntu: Which is Right For You?

Mint Linux vs Ubuntu: Which is Right For You?

March 12, 2022
Net Neutrality: What is it and Why Should You Care?

Net Neutrality: What is it and Why Should You Care?

March 12, 2022
Solid State Drives – Why You Should Buy One Today

Solid State Drives – Why You Should Buy One Today

March 12, 2022

Machine Learning Algorithms Every Beginner Should Know

January 25, 2022
  • Terms of Service
  • Privacy Policy
  • Careers

© 2021 Dotlayer.com

No Result
View All Result
  • About Us
  • Advertise
  • Blog
  • Careers
  • Contact
  • Contact Us
  • Get Featured
  • Home Layout 1
  • Home Layout 2
  • Home Layout 3
  • Privacy Policy
  • Security
  • Services
  • Subscribe To Dotlayer
  • Terms of Service
  • Write For Us

© 2021 Dotlayer.com

Welcome Back!

Login to your account below

Forgotten Password?

Retrieve your password

Please enter your username or email address to reset your password.

Log In