wordpress

Emoji feature was introduced in WordPress 4.2, which adds emoji support to the WordPress websites. To support Emojis, WordPress adds some additional stlyes and scripts on every page which is may result in your website loading speed. Many websites running on WordPress doesn’t need this emoji support, in this case you might want to remove this emoji script from header and improve website loading speed.

wp emoji script in header
To remove the Emoji script from header, Add this snippet to your themes functions.php

function disable_wp_emojis() {

  // removes all emoji scripts & styles 
  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 emoji from TinyMCE Editor
  add_filter( 'tiny_mce_plugins', 'disable_emojis_tinymce' );
}


function disable_emojis_tinymce( $plugins ) {
  if ( is_array( $plugins ) ) {
    return array_diff( $plugins, array( 'wpemoji' ) );
  } else {
    return array();
  }
}

add_action( 'init', 'disable_wp_emojis' );