Remove Dashicons from WordPress to Speed Up Load Times

Updated 02/06/2024, Posted 02/06/2024 by James Parsons James Parsons 0 Comments

Notice a "dashicons.min.css" file include on your website PageSpeed report? We did too! Here's how to remove it.

Simply add this to your WordPress functions.php file:

/**
 * Deregister dashicons on the front-end for non-logged in users
 */

add_action( 'wp_enqueue_scripts', 'my_deregister_styles', 100 );
function my_deregister_styles() {
    if(!is_user_logged_in()) {  
        wp_deregister_style( 'dashicons' );
    }
}

This will remove them from the front-end of your WordPress site and you'll see a small speed boost.

What are dashicons for?

Dashicons are used for various parts of the WordPress admin dashboard. The file that is loaded looks something like this:

  • /wp-includes/css/dashicons.min.css?ver=6.4.3

Why are these loading on the frontend then? For the WordPress admin bar. This way, if the user is logged into WordPress, they'll see the little bar across the top of the site. In that bar, they would ordinarily see the WordPress dashboard icons.

The problem is that these are being loaded for all visitors - even people that aren't users on your WordPress installation. This script dequeues these assets on the frontend, and only keeps them for people who will actually see them - WordPress users who are logged in.

Will this break my icons?

No, you'll still be able to see dashicons when logged in.

This only removes them for non-WordPress users who aren't seeing the WordPress dashboard icons anyway. For WordPress users, they will continue to load as before.

What is the impact?

The file is auto-generated and is usually rather small at around 61kb. When served compressed, it's likely even smaller.

If you have a WordPress performance plugin like WP Rocket, you may not even notice it, as it is probably removing this un-used CSS for you. In future versions of WordPress, this may even be removed automatically.

For others, it may be worth removing.

Related Code Snippets

Written by James Parsons

Hi, I'm James Parsons! I founded Content Powered, a content marketing agency where I partner with businesses to help them grow through strategic content. With nearly twenty years of SEO and content marketing experience, I've had the joy of helping companies connect with their audiences in meaningful ways. I started my journey by building and growing several successful eCommerce companies solely through content marketing, and I love to share what I've learned along the way. You'll find my thoughts and insights in publications like Search Engine Watch, Search Engine Journal, Forbes, Entrepreneur, and Inc, among others. I've been fortunate to work with wonderful clients ranging from growing businesses to Fortune 500 companies like eBay and Expedia, and helping them shape their content strategies. My focus is on creating optimized content that resonates and converts. I'd love to connect – the best way to contact me is by scheduling a call or by email.