WANT US TO SPEED UP YOUR SITE?
WANT US TO SPEED UP YOUR SITE?

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

Why Is Woocommerce So Slow – Here Is How To Fix It!

written by WP Fix It

June 13, 2017

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

4 Shares
WordPress Speed Up Service

You May Also Like…

22 Comments

  1. Wojtek Siodelski

    Hi

    I would like to remove geolocation from the main page only – how do I do that? it causes extra 5 seconds of delay and I only really need this on woocommerce pages.

    Reply
  2. Bruno

    I have the Enfold theme, it has been slow for quite a while but more recently
    the safari browser has been extremely slow to load menus and text on front and shop pages. Do you know of a fix for this.?

    Reply
  3. Joe

    “WooCommerce powers over 40% of the web”

    Have you got a source for this?

    Reply
  4. jon

    Once I install it, do I need to do anything, or does the plugin run in the background once activated?
    Thanks

    Reply
  5. daz

    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?

    Reply
    • WP Fix It Support

      Deactivate it. Try using WP Disable plugin to defer cart fragments.

      Reply
  6. Rowan

    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?

    Reply
  7. Namadi

    Please on which section of function.php should the snippet be pested

    Reply
  8. Mike

    Good and useful tutorial . Also cache plugins for WordPress could help to speed up WooCommerce website

    Reply
  9. Islam ELSHOBOKSHY

    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.

    Reply
  10. Nitsan.

    Worked a treat. Back to 97%, was 80 before.

    Reply
  11. caleb

    Does this work with the caching issues they have?

    Reply

Submit a Comment

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

LET US GET STARTED RIGHT AWAY

READY TO GET YOUR SITE FIXED