I have a site running with WooCommerce and WPBakery.
I'm trying to reduce unused CSS requests as highlighted by Page Speed Insights.
Currently, here are the CSS files that are being generated by the two plugins:
<link rel="stylesheet" id="wc-blocks-vendors-style-css" href="http://theme.test/wp-content/plugins/woocommerce/packages/woocommerce-blocks/build/wc-blocks-vendors-style.css?ver=1629402699" type="text/css" media="all">
<link rel="stylesheet" id="wc-blocks-style-css" href="http://theme.test/wp-content/plugins/woocommerce/packages/woocommerce-blocks/build/wc-blocks-style.css?ver=1629402699" type="text/css" media="all">
<link rel="stylesheet" id="js_composer_front-css" href="http://theme.test/wp-content/plugins/js_composer/assets/css/js_composer.min.css?ver=6.7.0" type="text/css" media="all">
I'm looking to either:
- De-register those stylesheets (as I have tried below).
deferall three of these stylesheets
I have tried the following below:
function remove_plugin_styles() {
wp_deregister_style( 'wc-blocks-style' ); // woocommerce
wp_deregister_style( 'wc-blocks-vendors-style-css' ); // woocommerce
wp_deregister_style( 'js_composer_front-css' ); // js composer (wpbakery)
}
add_action( 'wp_enqueue_scripts', 'remove_plugin_styles', 100 );
With the above wc-blocks-style and wc-blocks-vendors-style-css are successfully removed. But, js_composer_front-css is still loaded in.
Is there a way to either defer all these sheet (and any other plugin related css files), or remove them?