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

ADVERTISEMENTS

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.

🐧 If you liked this page, please support my work on Patreon or with a donation.
🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source & DevOps topics via:
CategoryList of Unix and Linux commands
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04

ADVERTISEMENTS
4 comments… add one
  • KristoZ Mar 1, 2017 @ 22:29

    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

  • sedlav Mar 2, 2017 @ 14:13

    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!.

  • Christian M. Grube Mar 2, 2017 @ 14:24

    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

  • idle Apr 13, 2017 @ 17:55

    It would be awesome if there were a config directive you could add to wp-config.php.

    Does such a thing exist?

Leave a Reply

Your email address will not be published. Required fields are marked *

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.