WooCommerce Cart Fragments Are Not Slowing Your Site Down

Home » WordPress Tutorials » WooCommerce Cart Fragments Are Not Slowing Your Site Down
  • woocommerce cart fragments

WooCommerce Cart Fragments Are Not Slowing Your Site Down

Every so often I have a client who is using WooCommerce and the client brings up that one of their WooCommerce scripts is adding 10+ seconds to their load time. This is usually the WooCommerce Cart Fragments JavaScript and there are even a number of plugins that disable this request.

Before we talk about how bad this request is, let’s talk about the following:

  1. What is the WooCommerce Cart Fragments script?
  2. How does it impact your website performance?
  3. What can you do about it?

What Does This Script Do?

The WooCommerce Cart Fragments script is an Ajax request to the server. It is dynamic and is used to serve people a dynamic cart. For example, if you have a shopping cart in your header, and you hover it, and it shows the products added to the cart, then you are using this script.

The script gives every person a unique cookie and tracks their cart contents throughout the website. This way when you are using server side caching, the content of the cart can be visible without the customer needing to visit the /cart/ page.

For many online shops, this is an integral piece of code. This is because users have become accustomed to being able to check their cart no matter where they are on the website. They are also used to being able to remove items from their cart without needing to be taken elsewhere.

Does the  WooCommerce Cart Fragments Script Slow Down Your Website?

It does, but not in the sense you would think. Your customers browser is downloading the data from your website. If it is taking 8 seconds for that to download, you are likely running on a slow and under-powered server. However, Ajax requests are by default asynchronous. Ajax requests do not prevent the website from being fully downloaded and interactive. This means that the user can do whatever they want. They can visit pages, add content, scroll through the website, etc.

If the site is on an under-powered server with a lot of visitors, this can lead to performance degradation. However, if you trying to run an online store on a $3 a month host, you are already making poor business decisions.

What Can I Do About It?

If you do not have a header shopping cart and have no use for its functionality, then disable it. To disable the functionality, install the Disable Cart Fragments plugin here.

Another option is to optimize your server to better handles these types of requests. This can be done by moving to a newer version of PHP, switching to a better hosting plater with less resource limits, and using server-side object caching to reduce database query time.

For the best WooCommerce performance, run your website on a fast server and stop stressing about what a performance test says. Consult an expert in website optimization who can help you improve your website’s load time without sacrificing a crucial piece of functionality.

By |2018-09-09T13:18:02+00:00September 9th, 2018|Categories: WordPress Tutorials|Tags: , , |0 Comments

About the Author:

Scott Hartley is a WordPress Developer who focuses on website performance optimization, SEO, and security. He can't tell you what a color wheel is but he knows the intricacies of making a website load quickly.

Leave A Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.