Website loading indicator, the delay caused by WooCommerce Ajax Cart Fragments

WooCommerce: Why & How to Disable Ajax Cart Fragments

Konet Team · · 1 min read

Slow performance and errors on WooCommerce websites are often caused by a large number of AJAX requests, because these requests are not cached. If you run a WooCommerce website and notice a large number of AJAX requests, disabling AJAX Cart Fragments can improve the stability of your website.

About WooCommerce Cart Fragments

WooCommerce “Cart Fragments” is a script that uses admin ajax to update the shopping cart without reloading the page. This feature slows down your website or breaks the caching of pages that do not actually need any shopping cart information.

For example, Cart Fragments on static posts, pages, custom post types and feed pages that contain no eCommerce functionality will reduce cacheability and therefore degrade server performance.

You can detect a website’s Cart Fragments with any web page speed test, or in your website’s Access Log by adding the following to your domain:

https://domain.com/?wc-ajax=get_refreshed_fragments

Cart Fragments will appear in the Access Log as follows:

10/Feb/2021:23:59:59 +0000|v1|1.1.1.1|www.domain.com|200|210|127.0.0.1:80|0.328|0.330|POST /?wc-ajax=get_refreshed_fragments HTTP/2.0||

Disabling Cart Fragments

  1. Add a plugin that can disable Cart Fragments, such as “Disable Cart Fragments” or “Perfmatters”, to your website.
  2. Follow this guide to disable Cart Fragments by editing your theme’s functions.php file.

Creative Commons BY 4.0 This article is licensed under Creative Commons Attribution 4.0 International (CC BY 4.0). You may republish it, provided you credit Konet as the source with a link to this article.

Share it Copied!