≡ Menu

How to disable smileys/emojis in WordPress headers to speed up the site

WordPress has smileys or so-called emojis added in version 4.2+. It added emoji character using javascript and other junk. It slows down the site for no real reason, and I do not use it at all. Here is how to remove unnecessary HTML and emoji URL calls to every page of your site and speed up your site.

Disable WordPress emoji

Disable WordPress emoji


How to disable emojicons/smileys introduced with WordPress

Edit your functions.php (make a backup first) located in themes folder and append the following code. In my case it was located in /var/www/html/wp-content/themes/twentysixteen/functions.php file:
$ vi /var/www/html/wp-content/themes/twentysixteen/functions.php
Append the following to disable it:

// Code credit http://wordpress.stackexchange.com/questions/185577/disable-emojicons-introduced-with-wp-4-2
function disable_wp_emojicons() {
  // all actions related to emojis
  remove_action( 'admin_print_styles', 'print_emoji_styles' );
  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_filter( 'wp_mail', 'wp_staticize_emoji_for_email' );
  remove_filter( 'the_content_feed', 'wp_staticize_emoji' );
  remove_filter( 'comment_text_rss', 'wp_staticize_emoji' );
 
  // filter to remove TinyMCE emojis
  add_filter( 'tiny_mce_plugins', 'disable_emojicons_tinymce' );
}
add_action( 'init', 'disable_wp_emojicons' );
 
function disable_emojicons_tinymce( $plugins ) {
  if ( is_array( $plugins ) ) {
    return array_diff( $plugins, array( 'wpemoji' ) );
  } else {
    return array();
  }
}
// remove the DNS prefetch
add_filter( 'emoji_svg_url', '__return_false' );

(Code credit: Christine Cooper)

Save and close the file. This made my site load faster. I hope this helps someone else too.

Share this on:

Your support makes a big difference:
I have a small favor to ask. More people are reading the nixCraft. Many of you block advertising which is your right, and advertising revenues are not sufficient to cover my operating costs. So you can see why I need to ask for your help. The nixCraft, takes a lot of my time and hard work to produce. If you use nixCraft, who likes it, helps me with donations:
Become a Supporter →    Make a contribution via Paypal/Bitcoin →   

Don't Miss Any Linux and Unix Tips

Get nixCraft in your inbox. It's free:



{ 3 comments… add one }
  • Christian M. Grube March 2, 2017, 2:24 pm

    Make Childtheme to edit functions.php, because an update will delete your changes.
    A better way is to write a plugin for changes like that.
    Use “My Custom Functions” Plugin for changes instead to write one by yourself.

    Greetings

    Reply
  • sedlav March 2, 2017, 2:13 pm

    I think is better to do the change as plugin instead of modify functions.php of your theme because if you update your theme we can say good by to the change!.

    Reply
  • KristoZ March 1, 2017, 10:29 pm

    Very nice! This made my site load twice as fast!
    Before the load time was 3.32s, but after the tweak: 1.55s. Thanks for the tip!
    My results, if anyone interested:
    http://imgur.com/RF51Oev

    Reply

Leave a Comment