Use code PERFMATTERS for an extra 10% off!
  1. Home
  2. Docs
  3. General
  4. Disable WooCommerce cart fragments AJAX (wc-ajax=get_refreshed_fragments)

Disable WooCommerce cart fragments AJAX (wc-ajax=get_refreshed_fragments)

WooCommerce sites, especially large ones, almost always encounter load time issues with the following AJAX request.

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

Even on our small WooCommerce test site, it took longer than any other request and wasn’t needed as this was on the homepage. On large sites, we have seen this account for up to 10-second delays. That’s right, 10 seconds.

wc-ajax=get_refreshed_fragments
wc-ajax=get_refreshed_fragments

Disable WooCommerce cart fragments

To disable WooCommerce cart fragments when nothing is in the cart, follow the steps below. Make sure you have WooCommerce installed and activated first.

Step 1

Click into the Perfmatters plugin settings.

Perfmatters plugin settings
Perfmatters plugin settings

Step 2

Make sure you’re on the “General” submenu.

Perfmatters General submenu
Perfmatters General submenu

Step 3

Scroll down to the “WooCommerce” section and toggle on “Disable Cart Fragmentation.” The feature will check to see if the woocommerce_cart_hash cookie exists, meaning something is in the cart. If the cookie isn’t present, then the cart fragments script will be disabled. This retains functionality while fixing the performance issue.

Disable WooCommerce cart fragments
Disable WooCommerce cart fragments

Step 4

Scroll down and click “Save Changes.”

Alternative: Delay cart fragments script

If you have any issues with the feature above due to your theme, an alternative is to simply delay the cart-fragments.min.js script until user interaction. This method will work for most WooCommerce sites. See how to delay JavaScript with Perfmatters.

Delay cart-fragments.min.js script on WooCommerce site
Delay cart-fragments.min.js script on WooCommerce site

Troubleshooting cart fragments

The cart fragments feature and or AJAX request in WooCommerce is used to update the cart total without refreshing the page. However, this definitely comes at a cost, and a lot of times depending upon your theme, isn’t even used or needed.

Some themes also allow you to change how your shopping cart works. So we’ve seen that some will use our Perfmatters feature to disable cart fragments and then change the shopping cart functionality with a theme option to get better results. 

If your theme only has an option to turn the shopping cart on or off, another route we’ve seen that sometimes works is to turn it off and instead use a free plugin like WP Menu Cart for the shopping cart.

Was this article helpful?

Related Articles