How to suppress the emoji module?

As the WordPress documentation says, Emoji are the ideograms or smileys (for example 🙂 ) used in electronic messages and Web pages. Originating in Japan on mobile devices, they are now commonly available on devices worldwide, ranging from mobile to desktop computers. Emoji are decorative, useful and they can actually make any website more friendly, maybe for this reason, the Emoji module is added as default by WordPress to all Themes but, what can we do if we don’t want to load this module?

Emoji keyboard example for Android by Kraftbj on WordPress

The WordPress Emoji module is independent of any theme, and just depends on two files (a little CSS code and a script) that are tipically added to the HTML <head> element. This addition is made through two functions, one attached to wp_head action with priority 7 (before the common css style files output), and the other attached to wp_print_styles action with default priority.

As in other cases that we want to modify the ouput of the default WordPress functions, we could think in adding a filter to them but, unfortunatelly, these functions haven’t got any relevant filter or parameter to modify their outputs however, instead of filtering, if you don’t want to load this module, the functions can easily be suppressed simply by removing their load actions.

So the solution is very easy, simply add this couple of lines with remove_action( etc. ) to the functions.php file of the theme –better inside a function attached to the action after_setup_theme–, and that’s all folks!, the outputs related to Emoji will disappear from your HTML.

function suppressing_emoji() {
    remove_action ( 'wp_head', 'print_emoji_detection_script', 7 );
    remove_action ( 'wp_print_styles', 'print_emoji_styles' );
add_action ( 'after_setup_theme', 'suppressing_emoji' );

Remember don’t forget the number 7 in the first remove_action. I hope this little code can help you.

Have a nice WordPressing!

Leave a Comment

   Mandatory field
You can use these HTML tags inside the commment.
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>