Disable Cart Fragments on WooCommerce: Complete Guide
The problem
wc-cart-fragments.js is a script loaded by WooCommerce on every page of your site. Its job: update the mini-cart counter in real time via an AJAX request to /?wc-ajax=get_refreshed_fragments.
On every page load:
- A ~10 KB JS file is loaded (+ jQuery as a dependency if not already present)
- An AJAX request is sent to the server
- The server runs PHP to rebuild the cart HTML
- The response travels across the network
On a 500-product catalog, every visitor browsing triggers this request even if their cart is empty. The result: degraded TTFB (Time To First Byte) and a server processing useless requests. It’s one of the first things I flag during a WooCommerce performance optimization review.
Measure the impact
Before disabling anything, measure. Open your browser DevTools (F12), Network tab, and filter by wc-ajax. Reload a product page. You’ll see the get_refreshed_fragments request with its response time.
On typical shared hosting, this request takes between 200ms and 800ms. On a well-configured server with Object Cache, more like 50-150ms. Either way, it’s a request that has no reason to exist on most pages.
Solution 1: Disable via PHP (recommended)
The cleanest method. Add this code to your child theme’s functions.php or in a snippet (Code Snippets, WPCodeBox, etc.):
add_action( 'wp_enqueue_scripts', function() {
if ( is_cart() || is_checkout() ) {
return; // Keep Cart Fragments on cart and checkout pages
}
wp_dequeue_script( 'wc-cart-fragments' );
}, 999 );
This disables the script on all pages except cart and checkout, where the real-time update is useful.
Variant: disable everywhere
If your theme doesn’t use an AJAX mini-cart (or if you use WooCommerce Block Checkout):
add_action( 'wp_enqueue_scripts', function() {
wp_dequeue_script( 'wc-cart-fragments' );
}, 999 );
Solution 2: Via Perfmatters (Script Manager)
If you use Perfmatters, you can disable wc-cart-fragments per page type from the Script Manager interface:
- Enable Script Manager in Perfmatters → Settings
- Navigate to a product page
- Open the Script Manager (admin bar)
- Find
wc-cart-fragmentsin the WooCommerce section - Disable it everywhere except
/cart/and/checkout/
The advantage: no code, visual management, reversible in one click.
Solution 3: Via WP Rocket
WP Rocket offers a native option:
- WP Rocket → Settings → Add-ons
- Enable “WooCommerce”
- The “Disable Cart Fragments” option appears
Warning: WP Rocket disables it everywhere, including on the cart page. If your mini-cart stops updating, you’ll know why.
What to check after
- The mini-cart: add a product, navigate to another page. Does the counter update? If not, that’s expected - it will update on the next page reload.
- The cart page: verify
/cart/still works (quantity updates, product removal). - The checkout: complete a full test order.
- Lighthouse: run an audit again. You should see improvement on Total Blocking Time (TBT) and potentially LCP.
Real-world impact
On stores I’ve optimized, disabling Cart Fragments removes 1 request per page and saves between 10 and 50 KB of JS (depending on whether jQuery is used elsewhere). On shared hosting, that’s typically 200-500ms saved on product page TTFB.
It’s a simple optimization, risk-free when done properly, with an immediate and measurable impact. For more context, cache plugins alone are not enough, disabling cart fragments is one of the prerequisites before layering cache on top.
Need a full audit of your WooCommerce store? Request a free audit.
Need a WooCommerce store audit?
I'll send you a personalized report with the top priorities to improve. Free, no strings attached.