The WooCommerce cart fragments problem (and how to actually fix it)

If you profile almost any WooCommerce store, you’ll find a request to admin-ajax.php firing on every single page — the homepage, blog posts, contact page, everywhere. That’s cart fragments, and it’s one of the most common and least understood drags on WooCommerce performance.

What cart fragments actually do

WooCommerce ships a script called wc-cart-fragments.js. Its job is to keep the little “cart” widget in your header up to date — the item count and total — without reloading the page. To do that, it makes an AJAX call to the server on page load to fetch the current cart state.

Useful idea. The problem is where it runs: on every page, for every visitor, whether or not there’s a cart widget in sight and whether or not the customer has anything in their cart.

Why it’s slow

Three reasons stack up:

  • It’s a POST request to admin-ajax.php, which means it bypasses your full-page cache completely. Every hit goes all the way to PHP and the database.
  • It’s session-based, so it often can’t even use an object cache cleanly.
  • On a loaded server, that round-trip regularly costs 200–500ms, and it competes with the rest of your page for the browser’s attention.

Multiply that across every page view and it’s a meaningful, site-wide tax on speed — and it shows up directly in your Core Web Vitals, particularly interaction responsiveness.

How to fix it properly

The lazy fix you’ll find online is “disable cart fragments everywhere.” Don’t do that blindly — on a lot of themes it breaks the live mini-cart, so the count stops updating when someone adds a product, and now you’ve traded speed for a broken buying experience.

The right approach is surgical:

  • Only load it where it’s needed. Dequeue the script on pages that have no cart interaction (homepage, blog, landing pages) and keep it on shop, product and cart pages. Most visitors land on content pages, so this alone removes the majority of the calls.
  • Update the cart count on add-to-cart instead of on every load. The widget doesn’t need to phone home on page one; it needs to react when the cart actually changes.
  • Make sure your cache respects sessions. If your full-page cache is serving cart pages to everyone, you have a bigger problem than fragments — fix the cache rules too.

Test it, don’t trust it

After any change, add a product from a few different pages and confirm the mini-cart still updates. Then reload a content page and check the network tab — the admin-ajax.php call should be gone there and still present on the shop. That’s the whole game: keep the behaviour, drop the cost.

Cart fragments are rarely the only thing slowing a store down — they’re usually one item on a list. If you want the full picture of where your time goes, start with why your store is slow (and it’s probably not the theme), or let me handle the lot on a performance engagement. A store audit is the quickest way to find out how much this one is costing you.

Want a hand with something like this?

Tell me the URL, the platform, and what’s stuck. I’ll come back with a straight answer.

Get in touch