Removing Unused Resources

Video Available (Signup to Access - Members Only)

While WordPress is an amazing platform, it seems that some often unused resources have been added to the core. These resources are requested each time someone visits your web site. Caching is a great way to reduce resources used by visitors, but this training will look at some of the resources and ways to disable them from loading, when unnecessary.

Removing Unused Resources

We will look at some of the more common resources used on WordPress sites, and if they are not being used on the frontend of your site, how to remove them to speed up your web site. After all, if you are not using them, why force regular site visitors to wait, as those unused resources are pulled down into their browser. These are resources you should not even be caching, if you site is using a caching system.

Dashicons

Dashicons is an amazing font, used by the admin area of your site, as well as in the admin toolbar on the frontend for logged in users. However, if someone is simply viewing your site, the dashicons font is not needed, but pulled anyways. Just take a look at the waterfall display for this very site below.

Unused Dashicons Font Loading - Frontend

This waterfall is created through GTMetrix, an amazing resource for those looking to get recommendations to improved their site speed. It will provide you with all sorts of information, including what resources are called for, so we can see what can be eliminated for speeding up the site. Since GTMetrix is seeing the site as a normal non-logged in viewer, we can see that Dashicons is being called. Let's disable it. Add the following code to your parent themes functions.php:

add_action( 'wp_enqueue_scripts', 'simply_remove_resources' );

function simply_remove_resources() {

    // Hide Dashicon Font from non-logged in viewers
     if( ! is_user_logged_in() )
    wp_deregister_style( 'dashicons' );

}

Here is that same waterfall, after the above code is added. Notice that Dashicons is no longer being requested.

No Dashicons Font Loading - Frontend

Source: https://wordpress.stackexchange.com/a/281482