How to Disable Dashicons on the Frontend in WordPress?

By default, WordPress loads dashicons on the front end of each WordPress website, even if no icons are being used on the front end.

The biggest disadvantage of this happening is that it affects site performance as it increases the number of HTTP requests and the overall page size.

Dashicons are primarily used in the WordPress admin dashboard. If no icons are being used on the front end, disabling them is the best option.

The code snippet below disables the dashicons on the front end for non-admin users.

php
/**
 * Disable Dashicons on Front-end
 */
function marverick_disable_dashicons_frontend()
{
    if (!is_admin()) {
        wp_deregister_style('dashicons');
    }
}
add_action('wp_enqueue_scripts', 'marverick_disable_dashicons_frontend');

Leave a Reply

Your email address will not be published. Required fields are marked *