Why is WooCommerce So Slow – Here is how to FIX IT!

Understand why is WooCommerce so slow…

Did you know WooCommerce is a POWER PACKED plugin to give your WordPress site the ability to sell online. While WooCommerce can be an amazing selling tool for your site you may wonder Why is WooCommerce So Slow. Well the short answer is that the plugin itself has allot of scripts and styles that is needed for it to do it’s magic.

Unfortunately these scripts and styles are loaded on every page inside your site and that really slows things down. Makes no sense to load items not needed on a page to post right?

Well we have some good news. There is a way you can tell WooCommerce to only load the scripts and styles it needs on pages and posts that WooCommerce is running.

There are two ways you can do this and we will show you both.

With a Plugin Way of Doing It

We have created a plugin called WC Speed Drain.  This plugin stops loading the extra items you do not need on non- WooCommerce pages or posts in your site and speeds up WordPress core admin-ajax.php file. 

You can download this plugin at the link below or simply do this inside your site by being logged into your WordPress administrative area and going to PLUGINS > ADD NEW and search for WC Speed Drain.

https://wordpress.org/plugins/wc-speed-drain-repair

Without a Plugin Way of Doing It

You can take the below code and add this into the functions.php file of your active theme. If you are not sure how to do this, comment below and we will guide you through it.  WE LOVE QUESTIONS!!!

add_action( 'wp_enqueue_scripts', 'child_manage_woocommerce_styles', 99 );

function child_manage_woocommerce_styles() {
    //remove generator meta tag
    remove_action( 'wp_head', array( $GLOBALS['woocommerce'], 'generator' ) );

    //first check that woo exists to prevent fatal errors
    if ( function_exists( 'is_woocommerce' ) ) {
        //dequeue scripts and styles
        if ( ! is_woocommerce() && ! is_cart() && ! is_checkout() ) {
            wp_dequeue_style( 'woocommerce_frontend_styles' );
            wp_dequeue_style( 'woocommerce_fancybox_styles' );
            wp_dequeue_style( 'woocommerce_chosen_styles' );
            wp_dequeue_style( 'woocommerce_prettyPhoto_css' );
            wp_dequeue_script( 'wc_price_slider' );
            wp_dequeue_script( 'wc-single-product' );
            wp_dequeue_script( 'wc-add-to-cart' );
            wp_dequeue_script( 'wc-cart-fragments' );
            wp_dequeue_script( 'wc-checkout' );
            wp_dequeue_script( 'wc-add-to-cart-variation' );
            wp_dequeue_script( 'wc-single-product' );
            wp_dequeue_script( 'wc-cart' );
            wp_dequeue_script( 'wc-chosen' );
            wp_dequeue_script( 'woocommerce' );
            wp_dequeue_script( 'prettyPhoto' );
            wp_dequeue_script( 'prettyPhoto-init' );
            wp_dequeue_script( 'jquery-blockui' );
            wp_dequeue_script( 'jquery-placeholder' );
            wp_dequeue_script( 'fancybox' );
            wp_dequeue_script( 'jqueryui' );
        }
    }
 }

Some Other Snippets Here:

/** Disable Ajax Call from WooCommerce */
add_action( 'wp_enqueue_scripts', 'dequeue_woocommerce_cart_fragments', 11);
function dequeue_woocommerce_cart_fragments() { if (is_front_page()) wp_dequeue_script('wc-cart-fragments'); }
 
/** Disable Ajax Call from WooCommerce on front page and posts*/
add_action( 'wp_enqueue_scripts', 'dequeue_woocommerce_cart_fragments', 11);
function dequeue_woocommerce_cart_fragments() {
if (is_front_page() || is_single() ) wp_dequeue_script('wc-cart-fragments');
}
 
/** Disable All WooCommerce Styles and Scripts Except Shop Pages*/
add_action( 'wp_enqueue_scripts', 'dequeue_woocommerce_styles_scripts', 99 );
function dequeue_woocommerce_styles_scripts() {
if ( function_exists( 'is_woocommerce' ) ) {
if ( ! is_woocommerce() && ! is_cart() && ! is_checkout() ) {
# Styles
wp_dequeue_style( 'woocommerce-general' );
wp_dequeue_style( 'woocommerce-layout' );
wp_dequeue_style( 'woocommerce-smallscreen' );
wp_dequeue_style( 'woocommerce_frontend_styles' );
wp_dequeue_style( 'woocommerce_fancybox_styles' );
wp_dequeue_style( 'woocommerce_chosen_styles' );
wp_dequeue_style( 'woocommerce_prettyPhoto_css' );
# Scripts
wp_dequeue_script( 'wc_price_slider' );
wp_dequeue_script( 'wc-single-product' );
wp_dequeue_script( 'wc-add-to-cart' );
wp_dequeue_script( 'wc-cart-fragments' );
wp_dequeue_script( 'wc-checkout' );
wp_dequeue_script( 'wc-add-to-cart-variation' );
wp_dequeue_script( 'wc-single-product' );
wp_dequeue_script( 'wc-cart' );
wp_dequeue_script( 'wc-chosen' );
wp_dequeue_script( 'woocommerce' );
wp_dequeue_script( 'prettyPhoto' );
wp_dequeue_script( 'prettyPhoto-init' );
wp_dequeue_script( 'jquery-blockui' );
wp_dequeue_script( 'jquery-placeholder' );
wp_dequeue_script( 'fancybox' );
wp_dequeue_script( 'jqueryui' );
}
}
}

Hope this was helpful and GET READY FOR SOME SPEED!!!

Never again with you ask “Why is WooCommerce So Slow”.

24 Comments On “Why is WooCommerce So Slow – Here is how to FIX IT!”

  1. This… actually worked lol, got the page load from 11s to 4s, I’ll have to look for how to get from 4 to like 1 maximum but still you guys are awesome.

  2. My page instantly slows down by about 8-10 seconds when Jetpack is enabled – and I need jetpack for WooCommerce. Any suggestions to help me out with this issue?

  3. Hey guys,

    thanks for creating the plugin. I think it is helping speeds a bit.

    The issue is now add to cart is not working on my home page.

    Any ideas?

Leave a Reply

Your email address will not be published. Required fields are marked *

Search Posts

Other Posts

QUESTIONS