Say Goodbye to Slow Loading Times. Here is The Ultimate Guide to Speeding Up Your WooCommerce Store with Code Snippets”

A slow-speed website can reduce your number of customers. When your website does not open in 3 seconds, customers visit your competitor’s website, and you lose sales.

Research shows that even a one-second delay in page load time can result in a 7% reduction in conversions.

If your website speed is slow, your website bounce rate will increase terribly, affecting your website’s performance. For example, if you want to buy clothes and search for a clothing website, and if that website takes time to load the page. You will go for another website because you have other options and don’t need to wait for a loading website.

Page speed optimization is very important, especially for your e-commerce website, Because your customers will not wait for you. They have other options.
In this blog, we will discuss how you can optimize your woocommerce store by adding some code snippets to your function php file. You can also read this blog post for more woocommerce snippets.
Following is the blog outline

  • Why is page speed important?
  • Tools to measure page speed.
  • Tips for fast E-commerce store.
  • 5 Woocommerce Code Snippets.

1:Why is page speed important?

The following stats will show you how important page speed optimisation is.

  1. According to Google, the average time for a mobile website page to load is 22 seconds, but 53% of mobile site visitors leave a page that takes longer than 3 seconds to load.
  2. Kissmetrics reports that 47% of customers expect a page to load in 2 seconds or less, But 40% of users with the website take 3 seconds to load.
  3. Kissmetrics found that if a website page takes one second longer to load, conversions could drop by 7%.
  4. Amazon revealed that they increased revenue by 1% for every 100 milliseconds of improvement to their site speed.

These statistics highlight how important page speed optimization is for your website’s and your business’s success.

2:Tools to measure page speed

Following are the tools you can use to measure the website’s performance. These tools also suggest website areas where you can improve your website performance.

  1. Google PageSpeed Insights analyzes the website’s content and provides suggestions to improve its performance on mobile and desktop devices.
  2. GTmetrix analyses your website’s page speed and suggests ways to improve it. It also provides waterfall charts that show how each element of your website loads.
  3. Pingdom tool allows you to test the load time of your website from different locations worldwide. It also provides a performance grade and suggestions for improvement.
  4. WebPageTest This tool provides a detailed analysis of your website’s load time and suggestions for improvement. You can also test your website from different locations, devices, and connection speeds.
  5. Lighthouse – This is an open-source tool by Google that can be run as a browser extension or from the command line. It analyzes your website’s performance, accessibility, and SEO and provides suggestions for improvement.

3:Tips for a fast E-commerce store

Following are tips for Woocommerce stores which can increase website speed.

  • Always choose the best Hosting service for your website. It will help you to improve your website speed.
  • While Selecting a theme, always consider an SEOfriendly theme. SEO-friendly themes ensure your website ranks higher in SERPs and attracts more organic traffic.
  • Insert woocommerce code snippets in your theme PHP file.
  • By Optimizing website images, you can significantly improve website loading time.
  • Use the CDN content delivery network to optimize page speed by storing website content on servers worldwide.
  • Minimizing HTTPS requests can be achieved by combining files, using sprites, and minifying code to reduce the number of requests made by the browser, thus improving website performance.

4:5 Woocommerce code snippets

1:Enable Caching in Woocommerce: These code snippets help reduce the website’s loading time.

add_filter( 'woocommerce_caching_enabled', '__return_true' );

2:Disable Card Fridgmments:

These Woocommerce code snippets help to reduce the card fridgments which cause sower down the website

add_filter( 'woocommerce_cart_fragments_refresh_interval', '__return_false' );

3:Minify Css:

This code snippet removes the query string from the CSS file, which can help to reduce the file size and improve page load times

add_filter( 'style_loader_src', 'remove_css_js_ver', 10, 2 );
function remove_css_js_ver( $src ) {
    if ( strpos( $src, '?ver=' ) )
        $src = remove_query_arg( 'ver', $src );
    return $src;

4:Defer JavaScript Loading:

This code snippet defers the loading of JavaScript files, which can help to speed up page load times

add_filter( 'script_loader_tag', 'add_defer_attribute', 10, 2 );
function add_defer_attribute( $tag, $handle ) {
    if ( 'jquery' !== $handle )
        return $tag;
    return str_replace( ' src', ' defer="defer" src', $tag );

5:Disable Unused WooCommerce Scripts:
By Inserting the following code, you can disable unused WooCommerce Scripts.

add_filter( 'woocommerce_enqueue_styles', '__return_empty_array' );
add_filter( 'woocommerce_enqueue_scripts', 'dequeue_woocommerce_cart_fragments', 11 );
function dequeue_woocommerce_cart_fragments() {
    wp_dequeue_script( 'wc-cart-fragments' );


In this blog, we discussed how important website speed optimization is. We also discussed improving it by applying measurements and inserting code snippets in your thems PHP file. We also mention how slow speed can affect your online business and cause you to lose customers. Adding the above code snippets can improve your website page speed and help your business grow.
If You have any questions, kindly comment below!:)Thanks

Categorized in: