Feature Requests

1 vote

Remove legacy use of dashicons from Attribute Swatches Plugin

The Attribute Swatches Plugin uses WordPress ‘dashicons’ on the frontend.

Themes such as CommerceGurus’ Shoptimizer, which are optimized for performance and conversions, deregisters the ‘dashicons’ style on the frontend, which results in the Attribute Swatches .css not being loaded loaded:

/**
* Remove dashicons in frontend for unauthenticated users.
*/
add_action( ‘wp_enqueue_scripts’, ‘shoptimizer_dequeue_dashicons’ );
function shoptimizer_dequeue_dashicons() {
if ( ! is_user_logged_in() ) {
wp_deregister_style( ‘dashicons’ );
}
}

I actually believe this is the correct approach and that the Theme has it right. Please let me explain why:

The dashicons were intended, by WordPress, for use in the admin area of a WordPress site. The Iconic plugin seems to only use 1 single icon on the frontend in:
‘iconic-woo-attribute-swatches-premium/assets/frontend/css/main.css’ on line 217 and 218.

The icon that seems to be used is ‘f147’ (a checkmark icon for display on e.g. a chosen color swatch).

The ‘dashicons.min.css’ stylesheet is 28KB that needs to be loaded just for the sake of 1 icon. This is not very nice in terms of performance.

I would really recommend that the plugin uses a different icon set e.g. the FontAwesome family of icons instead, just like e.g. Elementor and WooCommerce itself already does. The font-awesome.min.css is less than 7KB when loaded.

If you want to keep using a checkmark you could, for example, do the following:
Change line 217 and 218 in ‘iconic-woo-attribute-swatches-premium/assets/frontend/css/main.css’ to:
font-family: FontAwesome;
content: “f00c”;

And then in ‘iconic-woo-attribute-swatches-premium/iconic-woo-attribute-swatches.php’ line 338 remove the ‘dashicons’ array parameter:
wp_register_style( ‘iconic-was-styles’, ICONIC_WAS_URL . ‘assets/frontend/css/main.min.css’, array( ‘dashicons’ ), self::$version );

I believe this is definitely something that would benefit all Iconic customers when it is fixed, would add to performance, and prevent others from having the .css issue I experienced.

Category: Attribute Swatches chris shared this idea

Leave a Reply

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

Powered by Simple feature Requests