• Resolved Miguel

    (@mhagenaars)


    Hello guys,

    Woocommerce is loading alot of new stylesheets in my source code which I dont need. This is after the update to 8.0.

    Please take a look at this site: https://demo2.zeroparts.eu/

    In the source code you see a big list:
    wc-blocks-style-all-reviews-css
    wc-blocks-style-customer-account-css

    etcetera…

    How is this possible and how to get rid off it immidiately?

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter Miguel

    (@mhagenaars)

    Found the solution adding this to the functions.php:

    function disable_wp_blocks() {
    $wstyles = array("wc-blocks-style","wc-blocks-style-active-filters","wc-blocks-style-add-to-cart-form","wc-blocks-packages-style","wc-blocks-style-all-products","wc-blocks-style-all-reviews","wc-blocks-style-attribute-filter","wc-blocks-style-breadcrumbs","wc-blocks-style-catalog-sorting","wc-blocks-style-customer-account","wc-blocks-style-featured-category","wc-blocks-style-featured-product","wc-blocks-style-mini-cart","wc-blocks-style-price-filter","wc-blocks-style-product-add-to-cart","wc-blocks-style-product-button","wc-blocks-style-product-categories","wc-blocks-style-product-image","wc-blocks-style-product-image-gallery","wc-blocks-style-product-query","wc-blocks-style-product-results-count","wc-blocks-style-product-reviews","wc-blocks-style-product-sale-badge","wc-blocks-style-product-search","wc-blocks-style-product-sku","wc-blocks-style-product-stock-indicator","wc-blocks-style-product-summary","wc-blocks-style-product-title","wc-blocks-style-rating-filter","wc-blocks-style-reviews-by-category","wc-blocks-style-reviews-by-product","wc-blocks-style-product-details","wc-blocks-style-single-product","wc-blocks-style-stock-filter","wc-blocks-style-cart","wc-blocks-style-checkout","wc-blocks-style-mini-cart-contents","classic-theme-styles-inline");
    
    foreach ($wstyles as $wstyle){
     wp_deregister_style($wstyle);  
    }
    
    $wscripts = array("wc-blocks-middleware","wc-blocks-data-store");
     foreach ($wscripts as $wscript){
     wp_deregister_script($wscript);  
    }
    }
    add_action( "init", "disable_wp_blocks",100 );
    matt-thomas-photography

    (@mattthomas-photography)

    Where did you find the code to add out of interest? I’ve had similar issues on my site and luckily Asset Clean you can just select the CSS but been looking for a function code as rather frustrating!

    Thread Starter Miguel

    (@mhagenaars)

    Hey @mattthomas-photography,

    I am very focused on super clean coded web building with Gutenberg and Woocommerce so this solution was very important for me.

    I found this code here: https://wordpress.stackexchange.com/questions/391126/remove-woocommerce-block-styles

    matt-thomas-photography

    (@mattthomas-photography)

    Looks like it’s just been added as been looking for a function code since the 8.0 launch. Saw that page before but the old versions didn’t work, glad this new one does though! Way too many extra CSS files for sites that don’t need or function with them

    Interesting, I was looking for something else, but stopped in to read this post.

    Here is what I applied recently, took a while to figure out that one needs to “deregister” and “deque” to make this work properly.

    //Remove Gutenberg Block Library CSS from loading on the frontend
    function smartwp_remove_wp_block_library_css(){
    	wp_deregister_style('wp-block-library');	
    	wp_dequeue_style( 'wp-block-library' );
    	wp_dequeue_style( 'wp-block-library-theme' );
    	wp_dequeue_style( 'wc-blocks-style' ); // Remove WooCommerce block CSS
    } 
    add_action( 'wp_enqueue_scripts', 'smartwp_remove_wp_block_library_css', 100 );
    matt-thomas-photography

    (@mattthomas-photography)

    @jandal nice simple code that! Tested and works to remove from the front end all those extra scripts. The nice thing about the first code is that it also removes from the WP admin as well

    Hey there @jandal,

    Thank you so much for adding your input! Some of our customers might indeed find this guide helpful!

    We appreciate you being an active part of the community ??

    Have a wonderful day!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Alot of stylesheet requests after update 8.0’ is closed to new replies.