Skip to content

Early-bird lifetime licence: $199 once, for the first 200 buyers only. See the offer

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.

  • Type PHP
  • Runs Everywhere (runs as WordPress loads)
  • Tested with WordPress 7.1
PHP
<?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.

Move your snippets over this afternoon.

Importing changes nothing until you switch over, and your old shortcodes keep working.