How to Disable Emojis in WordPress

Guy Dumais
Guy Dumais
Cover Image for How to Disable Emojis in WordPress

What are WordPress Emojis?

Emojis are icons that can be inserted into comments by your visitors, like this one :p. They are similar to those used on social networks and largely used by Internet users. However, if you disable the comments feature in WordPress, Emojis become unnecessarily loaded by visitors, increasing slightly the loading time of each web page which hurts your SEO performance.

PHP code to disable Emojis

Here is the PHP code that allows you to disable all the Emojis features in WordPress. Simply copy and paste this PHP code into the functions.php file of your WordPress theme and you're done.

Loading...

PHP Code Features

INIT Action: We inject this code into the init action hook, which is executed before the wp_enqueue_scripts action hook, the step where the Emojis are loaded among other stylesheets and javascript codes.

  • Anonymous Function: Using an anonymous function rather than a named function, saves memory in the Global Namespace, which is already heavily loaded by WordPress and third-party plugins. WordPress itself loads thousands of functions and PHP variables for processing each single Web request. And since this function needs to be executed only once during the client's request processing, why keep it in memory?
  • PHP Memory Release: Finally, we use the PHP unset($af) instruction to remove from memory our dynamically created anonymous function. By saving our anonymous function in a global variable $af, allows us to delete it at a later step since anonymous functions are not eliminated immediately after their usage by the PHP Garbage Collection system.

Comments:

    Share:


    By using this website, you agree to our use of cookies. We use cookies to provide you with a great experience and to help our website run effectively. Read our Terms and Conditions and Privacy Policy to learn more.