Caching

WooCommerce Cart Fragment Performance

Intermediate
High

What Cart Fragments Are

WooCommerce includes a JavaScript file called cart-fragments.js that runs on every page of your store. Its purpose is to update the mini-cart widget — the small cart icon showing the number of items — by making an AJAX request to the server after each page load. This request asks WordPress to regenerate the cart HTML fragment and send it back, ensuring the cart count is always current. The problem is that this AJAX call fires on every single page, even when the visitor has an empty cart.

How cart fragments affect performance

The cart fragment AJAX request typically adds 200-800 ms to each page load, depending on server speed. It creates a POST request to /?wc-ajax=get_refreshed_fragments that WordPress must process through the full PHP stack, including loading WooCommerce session data. This request:

  • Bypasses page caching — AJAX POST requests are not served from cache, so even a fully cached page still triggers a server-side PHP execution.
  • Adds server load — on high-traffic stores, cart fragment requests can account for a significant portion of total server requests.
  • Blocks other resources — the browser may delay rendering other content while processing the AJAX response.

When cart fragments are necessary

Cart fragments serve a real purpose: they keep the mini-cart accurate across page loads without requiring a full page refresh. If your store uses a header mini-cart widget that displays the current item count, cart fragments keep that count in sync. Disabling them entirely means the cart icon will not update until the page is fully reloaded.

Strategies for reducing the impact

The key is limiting where and when cart fragments run rather than disabling them blindly:

  • Disable on non-shop pages — if your site has a blog, landing pages, or other non-WooCommerce pages, cart fragments do not need to run there. Several optimization plugins allow you to dequeue the script selectively.
  • Disable for empty carts — if a visitor has no items in their cart, there is nothing to update. Some plugins only load cart fragments when the cart session is active.
  • Replace with a lightweight alternative — some themes and plugins replace the full cart fragment system with a simpler counter that updates only on add-to-cart actions.

Tools That Can Help

WP Rocket and Perfmatters both offer options to disable or defer cart fragment loading on specific pages. Query Monitor can help identify the cart fragment request in your page’s network activity.

Further Reading

Related Articles

Cart fragments are one of the main reasons WooCommerce pages are harder to cache than standard WordPress content.
Understanding page caching clarifies why cart fragment AJAX requests bypass the cache and add server load.

Need help with this?

Mochyon specializes in WordPress Core Web Vitals optimization. We diagnose, fix, and verify — with a named human accountable for the result.

Get help from Mochyon