← Back to All Snippets

Disable Dashicons CSS for Unauthenticated Guest Visitors

⚡ Target: functions.php 🔒 Tested: WP 6.6+ / PHP 8.2+ 💻 Lang: PHP
PHP (functions.php)
add_action( 'wp_enqueue_scripts', function() {
    if ( ! is_user_logged_in() ) {
        wp_deregister_style( 'dashicons' );
    }
}, 100 );

Prevents loading the heavy 30KB Dashicons font and stylesheet for normal site visitors who are not logged into the WordPress admin.

← Back to All Snippets Explore Dev Tools →