Remove Dashicons from WordPress to Speed Up Load Times

James Parsons by James Parsons Updated Feb 6th, 2024

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 Entries

Written by James Parsons

James Parsons is the founder and CEO of Content Powered, a premier content marketing agency that leverages nearly two decades of his experience in content marketing to drive business growth. Renowned for founding and scaling multi-million dollar eCommerce businesses through strategic content marketing, James has become a trusted voice in the industry, sharing his insights in Search Engine Watch, Search Engine Journal, Forbes, Entrepreneur, Inc, and other leading publications. His background encompasses key roles across various agencies, contributing to the content strategies of major brands like eBay and Expedia. James's expertise spans SEO, conversion rate optimization, and effective content strategies, making him a pivotal figure in the industry.