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”.
Hello, I have tried it and it improved my performance a lot, congratulations
Glad this worked for you!
Does this work with the caching issues they have?
Yes.
Worked a treat. Back to 97%, was 80 before.
Awesome sauce!
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.
Love YA!
Good and useful tutorial . Also cache plugins for WordPress could help to speed up WooCommerce website
Please on which section of function.php should the snippet be pested
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?
Did you know we have a special product made to get your site blazing fast and deal with speed issues? See full details at https://www.wpfixit.com/product/wp-sup/
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?
Deactivate it. Try using WP Disable plugin to defer cart fragments.
Once I install it, do I need to do anything, or does the plugin run in the background once activated?
Thanks
Activate and forget.
“WooCommerce powers over 40% of the web”
Have you got a source for this?
Yes at the link below. Make sure to click on the “ENTIRE INTERNET” tab. Guess you do not believe us uh. We do not make things up here in our articles.
https://trends.builtwith.com/shop