Remove WooCommerce Styles and Scripts

I’ve recently started working with WooCommerce for a client. IMHO, it’s absolutely the most brilliant and easy-to-use shopping cart for WordPress.

However, you know me and I hate plug-ins and bloat. Here’s how to disable all the extra style-sheets and scripts WooCommerce loads througout your web site, and restricts them to just loading in your store:

Add this to your theme’s functions.php

Another way, is to remove the functions all together (thanks to WPSMITH):

Genesis Framework

Genesis empowers you to quickly and easily build incredible websites with WordPress. Whether you're a novice or advanced developer, Genesis provides the secure and search-engine-optimized foundation that takes WordPress to places you never thought it could go. It's that simple - start using Genesis now!

Take advantage of the 6 default layout options, comprehensive SEO settings, built-in Schema.org markup, rock-solid security, flexible theme options, cool custom widgets, custom design hooks, and a huge selection of child theme that make your site look the way you want it to. With automatic theme updates and world-class support included, Genesis is the smart choice for your WordPress website or blog.


Become a StudioPress Affiliate

Comments

  1. says

    It’s fantastic, thanks, speeds up home page no end and stopped the ridiculous ajax calls.

    One question, how would one go about adding this to other pages that dont require the woocommerce bloat code?

    Thanks again

  2. says

    Mhh all codes from your site and in the comment doesn’t work. I’ve changed the ‘ with the correct ‘. Must I change something for my template? I use superstore from woocommerce. Thanks for help.

  3. says

    Solosails, I prefer to use the following if statement instead:

    if ( ! is_woocommerce() && ! is_cart() && ! is_checkout() ) {
    
    }
    • says

      @Jeff, Thank you for that, I was aware that the way I did it was pretty clunky, but it shows my lack of knowledge in coding!

      Cheers All

  4. says

    Been pulling my hair out trying to dequeue “wc-add-to-cart-variation” javascript. If anyone else is having this problem add the following to the function above: wp_deregister_script(‘wc-add-to-cart-variation’);

    Deregistering it will remove it completely.

Leave a Reply