Skip Navigation

WooCommerce Blocks loads extra Google Fonts files on the front-end

Open

Reported for: Toolset WooCommerce Blocks 2.8.1.1

Symptoms

When Toolset WooCommerce Blocks plugin (aka WooCommerce Views) is active you may see Google Fonts added to the page source on the front-end, pointing to https://fonts.googleapis.com/.

This is the same issue as previously reported and fixed for Views/Blocks, which also affects the Toolset WooCommerce Blocks plugin.
The problem occurs because assets required for the back-end editor are also loaded on the front end, when not required.

Workaround

This will be fixed in any upcoming release of this plugin.
In the meantime you can dequeue the unnecessary CSS files by adding the following PHP snippet to your site (at Toolset > Settings > Custom Code, or your theme’s functions.php file).

add_action( 'wp_print_styles', 'ts_dequeue_styles', 1 );
function ts_dequeue_styles( $handles ){

  global $wp_styles;
  $wcv_styles = $wp_styles->registered['woocommerce_views-block-style-css'];
  // dequeue & deregister existing style with dependencies 
  wp_dequeue_style( 'woocommerce_views-block-style-css' );
  wp_deregister_style( 'woocommerce_views-block-style-css', $wcv_styles->src );
  // re-enqueue same style minus dependencies
  wp_enqueue_style( 'woocommerce_views-block-style-css', $wcv_styles->src, array(), $wcv_styles->ver );
}

Leave
a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>