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.

scott hartley

About the author

Scott is a web performance geek, lover of all things coffee, and avid video game player. His WordPress work delves into web performance, web security, and SEO.

3 thoughts on “WooCommerce Cart Fragments Are Not Slowing Your Site Down”

  1. So in the same sense, wince wp-admin-ajax is also asynchronous, practically speaking it too shouldn’t be slowing your website, even if the gtmetrix says it is?

    • Correct practically speaking if you have a 5 second admin-ajax request it won’t stop the rest of the page from downloading. So you can have a site that renders and is usable and ready in 2 seconds but a fully loaded time of 5 seconds if the admin-ajax is too slow.

      Now, that being said if this is an essential bit of functionality you should highly consider a good webhost like wpengine, kinsta, cloudways, siteground, etc


Leave a Comment