Remove Dashicons from WordPress to Speed Up Load Times
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.
October 23, 2024
it totally makes sense to remove dashicons if they only show up for logged-in users! cheers, teresia
November 05, 2024
Hey Teresia!
You're definitely right about taking out dashicons for users who aren't logged in. It can really help with loading times and every little bit makes a difference!
I've had clients see better speeds from optimizing the frontend scripts so it's definitely worth trying out.
Feel free to let me know if you want any more WordPress tips! 😊