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 – but it’s heavy! I’ll show you how to remove the cruft!

Option 1

There are a couple of ways to do this. The easiest is to remove the three primary stylesheets using a simple filter in functions.php

Option 2

If you want fine grain control over what appears where, then this function uses a conditional tag to dequeue styles and scripts.

Option 3

Kill all the things, forever. You’ll write your own styles, because you’re a fucking ninja.

Further reading:

WooCommerce has a page dedicated for style & script management. Also, take a look at the PHP Class responsible for enqueuing styles and scripts.

Thanks to everyone who’s suggested things in the comments. Peer code-review is amazing, and it’s why I share this stuff.

Author: Greg Rickaby

Greg is Lead Front-End Developer at WebDevStudios and author of a children’s book titled, Creating a Website: Design and Build Your First Site!.

22 thoughts on “Remove WooCommerce Styles and Scripts”

  1. Since this is a pretty high-ranking article, I thought I’d add in this: Select2 as a library has effectively been abandoned, so as of WooCommerce 3.2x they added SelectWoo, which is a fork of the original Select2 with some Woo-specific stuff in there. As this is now enqueued under a different handle (but still basically throws in Select2-classed DOM elements), you might notice that if you’ve dequeued Select2 but NOT SelectWoo, then your country dropdown field might look weird. Easy solution: dequeue SelectWoo:

    wp_dequeue_script(‘selectWoo’);
    wp_deregister_script(‘selectWoo’);

  2. Hi, you really save my day man, I’m crying of joy!! With the new woocommerce update, I was having a lot of problems with ajax, but I could solved everything thanks to your post. Tks Tks Tks Tks forever !!!

  3. 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.

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

    if ( ! is_woocommerce() && ! is_cart() && ! is_checkout() ) {
    
    }
  5. 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.

  6. 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

Leave a Reply