Load Dashicons for logged-in users only
The Dashicons icon font is loaded on the public site for the admin bar. Visitors who aren’t logged in don’t need it.
<?php
add_action(
'wp_enqueue_scripts',
static function () {
if ( ! is_user_logged_in() ) {
wp_dequeue_style( 'dashicons' );
}
},
100
);
Good to know
If your theme or a plugin shows Dashicons to visitors, they still load (WordPress keeps styles other styles need).
In these packs
- Performance: Small changes that save the server and the browser some work.