You can disable Ajax cart fragments in WooCommerce by dequeuing the wc-cart-fragments script on pages where a live-updating cart widget isn’t needed, cutting an extra background request that can slow down page load.
Why Ajax Cart Fragments Can Hurt Performance
- WooCommerce calls
?wc-ajax=get_refreshed_fragmentson nearly every page to keep the cart widget updated - This runs even on pages with no cart widget or no way to add products at all
- Performance tools like GTmetrix or PageSpeed Insights often flag this request as a slowdown source
- Disabling it selectively can meaningfully cut requests without losing real functionality
Step 1: Dequeue the Cart Fragments Script Selectively
Rather than disabling it everywhere (which can break a live cart widget you do want), target only the pages where it isn’t needed.
/** Disable Ajax cart fragments everywhere except the shop, cart, and checkout */
add_action( 'wp_enqueue_scripts', 'limit_cart_fragments_script', 99 );
function limit_cart_fragments_script() {
if ( is_shop() || is_product_category() || is_cart() || is_checkout() ) {
return;
}
wp_dequeue_script( 'wc-cart-fragments' );
}Troubleshooting
The cart widget count stops updating without a page reload
That’s the expected tradeoff — cart fragments are exactly what powers the “add to cart without reload” widget update. If you need that behavior on specific pages, exclude those pages from the dequeue condition as shown above.
No noticeable speed improvement after disabling it
If your theme or a plugin re-enqueues the script separately, the dequeue may run before that later enqueue — try increasing the priority number on the wp_enqueue_scripts action so it runs last.
Redirect-to-cart setting makes fragments pointless anyway
If “redirect to the cart page after successful addition” is enabled in WooCommerce settings, the Ajax fragment update rarely matters since the page reloads on every add-to-cart regardless.
Frequently Asked Questions
Should I disable cart fragments on every page?
Only if you have no dynamic cart widget anywhere, or you enable the cart-redirect setting instead. Most stores are better off excluding just the pages that don’t need it, like static content pages.
Does this affect the Ajax add-to-cart button itself?
No, Ajax add-to-cart and cart fragments are related but separate — this snippet only stops the fragment refresh request, not the add-to-cart button’s own behavior.
Is there a plugin alternative to this snippet?
Yes, several performance plugins include a toggle for this exact setting if you’d rather manage it through an admin screen instead of code.
Conclusion
Selectively dequeuing the cart fragments script is a quick way to disable Ajax cart fragments in WooCommerce without losing the live cart widget where you actually need it. Test your cart widget behavior on the pages you exclude to confirm nothing important breaks.
See also How to Disable a Plugin for Customers or Shop Managers in WooCommerce.
Prefer no code? All-in-One Utilities Woo Add-on handles this kind of change from a settings screen. Its Bulk prices, subscription insights and cart fragments guide also shows how.