Remove WooCommerce Script and CSS files in WordPress

WooCommerce Tutorial: In simple steps, going to show you how to remove Woocommerce script and css files in WordPress from unnecessary pages. The following codes are tested by using WordPress Child Theme and working absolutely fine.

About WooCommerce: Woocommerce is a great and widely used WordPress plugin for a WordPress site to add e-commerce functionalities. Its great support, docs, and add-ons make it first choice among WordPress users for both developers and non-developers.

Why remove Woocommerce script and css files in WordPress?

As a great e-commerce plugin, woocommerce load too many JS and CSS files as soon as you activate it. Those JS and CSS files load in all posts and pages where you don’t need including woocommerce relative pages. Site loading speed also increases and visitors get disturbed which is not good for any e-commerce site owner.

To get over this problem, here I am going to give you the most effective WooCommerce JS and CSS file optimization tips without disturbing site performance, visitors and eCommerce functionalities.

Here is how to do?

Step 1: Open functions.php file (Assuming you are using WordPress child theme)

Step 2: Copy and paste this below codes

//* Dequeue scripts and styles
add_action( 'wp_enqueue_scripts', 'bn_disable_woocommerce_loading_css_js' );

function bn_disable_woocommerce_loading_css_js() {

// Check if WooCommerce plugin is active
if( function_exists( 'is_woocommerce' ) ){

// Check if it's any of WooCommerce page
if(! is_woocommerce() && ! is_cart() && ! is_checkout() ) {         

    ## Dequeue WooCommerce styles

    ## Dequeue WooCommerce scripts
    wp_deregister_script( 'js-cookie' );
    wp_dequeue_script( 'js-cookie' );
    wp_dequeue_script( 'vc_woocommerce-add-to-cart-js' );


Step 3: Save it and you are done

Step 4: Now check your site performance speed. You will see the improvements

Step 5: Clarification:

With add_action, I call the ‘ bn_disable_woocommerce_loading_css_js ’ functions with wp_enqueue_scripts. Next in actual functions, First I checked woocommerce functions exits or not with “ is_woocommerce ”. Then dequeue the woocommerce css and js files except woocommerce, cart, checkout pages.

4 thoughts on “Remove WooCommerce Script and CSS files in WordPress”

  1. HI, thanks for this. Quick note. Line 16 should be



  2. Hello, nice article. I would like to ask you is it is safe to remove jquery.blockUI.min.js , add-to-cart-variatioon.min.js , underscore.min.js , wp-util.min.js
    I remove these scripts and the site run fast without issues. What is youw opinion?


    • You may remove any script or files as long as they are not necessary for specific pages with conditional logic. Like, if you don’t have any woo functions on the home page then remove all woo commerce CSS and js files from the homepage with conditional logic.


Leave a Comment

Item added to cart.
0 items - $0.00