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
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' );
Save and close the file. This made my site load faster. I hope this helps someone else too.
🐧 Get the latest tutorials on Linux, Open Source & DevOps via:
- RSS feed or Weekly email newsletter
- Share on Twitter • Facebook • 4 comments... add one ↓
Category | List of Unix and Linux commands |
---|---|
File Management | cat |
Firewall | Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04 |
Network Utilities | dig • host • ip • nmap |
OpenVPN | CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04 |
Package Manager | apk • apt |
Processes Management | bg • chroot • cron • disown • fg • jobs • killall • kill • pidof • pstree • pwdx • time |
Searching | grep • whereis • which |
User Information | groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w |
WireGuard VPN | Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 |
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
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!.
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
It would be awesome if there were a config directive you could add to wp-config.php.
Does such a thing exist?