Instructor Lead On-Demand Learning Courses - August Big $10 Sitewide Extravaganza All Pro Web Designs and Udemy are happy to offer this special to you, good only on dates: 08/21-08/31 Act Now!

Disable Emojis in WordPress 4.2+ For a Faster Page Load

As of WordPress 4.2, a new feature was introduced that allows you to use the new emojis (the tiny smiley icons). While on some WordPress setups is useful, in many situations, especially when you are not using WordPress as a blog, you just don’t need them and the file /wp-includes/js/wp-emoji-release.min.js is loaded along with extra inline JavaScript code.

As I want my page to load as fast as possible and have the HTML code clean when analysing the source code (as a developer), I’d rather have all that extra code removed, especially since it loads on every page of my website. There are 2 ways in which you can do that. We’ll start with the most convenient one:

1) Disable Emojis plugin

This is the quickest way to do that and emoji’s will still work in browsers which have built in support for them. This plugin simply removes the extra code bloat used to add support for emoji’s in older browsers.

2) Use the code below

I prefer to edit functions.php or to have a custom plugin with snippets as the block of code is pretty small. If you are comfortable with that, here’s the code that you can use:

function bit_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', 'bit_disable_emojicons_tinymce' );
}

add_action( 'init', 'bit_disable_wp_emojicons' );

function bit_disable_emojicons_tinymce( $plugins ) {
    if ( is_array( $plugins ) ) {
        return array_diff( $plugins, array( 'wpemoji' ) );
    } else {
        return array();
    }
}
Note: If you prefer to have the old smilies from previous WordPress versions, while removing the new ones, you can use Classic Smilies plugin.

The post Disable Emojis in WordPress 4.2+ For a Faster Page Load appeared first on Bit Repository.

See more about Disable Emojis in WordPress 4.2+ For a Faster Page Load

Instructor Lead On-Demand Learning Courses - August Big $10 Sitewide Extravaganza All Pro Web Designs and Udemy are happy to offer this special to you, good only on dates: 08/21-08/31 Act Now!

Leave a Reply