How to Disable WooCommerce Cart Fragments (3 Methods)

Editorial Team

· Last Update On:

·

WooCommerce fires a background server request on every single page of your store by default. Not just product pages. Not just the cart.

Every page, for every visitor, including people reading a blog post who have never added anything to their cart.

This background request is called cart fragments. Its job is to keep the cart item count in your header updated in real time. That sounds useful.

The problem is that it runs even when there is nothing to update, adding an unnecessary HTTP request to every page load across your entire site.

Disabling cart fragments on non-cart pages is one of the fastest performance improvements available to any WooCommerce store. It takes under 10 minutes regardless of which method you use.

Key Takeaways

  • WooCommerce loads cart-fragments.min.js on every page, which fires an AJAX request to update the cart count even on pages with no cart interaction.
  • Disabling it on non-cart pages removes one HTTP request from every page load site-wide.
  • Three ways to do it: a free plugin, a WooCommerce setting, or a small PHP snippet.
  • After disabling, the cart count in your header updates when visitors visit the cart or checkout page, not in real time on every page.
  • Do not disable it entirely if your theme depends on real-time cart count updates throughout the checkout flow.
  • Run a browser network test before and after to confirm the fix worked.

What Cart Fragments Actually Does

When a visitor lands on any page of your WooCommerce store, the browser loads a JavaScript file called cart-fragments.min.js. That script immediately fires a POST request to your server asking for updated cart data. The URL looks like:

yourstore.com/?wc-ajax=get_refreshed_fragments

Your server processes this request, checks the visitor’s cart, and sends back the current item count and cart total. The JavaScript then updates the cart icon in your header with that data.

This happens on your homepage. On category pages. On blog posts. On your About page. On pages that do not even have a visible cart icon.

The request itself takes 100-500ms depending on your server speed. It blocks some caching configurations from working efficiently. And it adds server load from every single page view across your store, not just from shoppers actively browsing products.

Method 1: Plugin (No Code, 2 Minutes)

If you want to disable cart fragments without touching code, this is the quickest option.

Install Disable Cart Fragments from the WordPress plugin directory. It is free, lightweight, and does one thing.

  1. Go to Plugins in your WordPress admin
  2. Click Add New Plugin
  3. Search for Disable Cart Fragments
  4. Click Install Now, then Activate

That is it. The plugin deactivates the cart fragments script on all non-cart pages automatically. No settings to configure.

When to use this method: You prefer not to edit theme files or want the simplest approach.

Trade-off: Adds one small plugin to your stack. The overhead is negligible for a fix this focused, but it is still one more update obligation.

Method 2: WooCommerce Native Setting

WooCommerce added a setting to control cart fragments behaviour without requiring a plugin or code. This is worth checking before doing anything else.

  1. Go to WooCommerce in your WordPress admin
  2. Click Settings
  3. Click the Advanced tab
  4. Look for a setting related to cart or AJAX cart updates

The location of this setting varies by WooCommerce version. In some versions it appears under WooCommerce, Settings, Advanced as Enable AJAX add to cart buttons on archives. In others it is accessible through the WooCommerce feature flags under Settings, Advanced, Features.

If you find a cart fragment or AJAX cart option, disable it and save. Test by following the verification steps at the end of this guide.

When to use this method: It is the cleanest approach: no plugin, no code, no theme changes.

Trade-off: This setting is not present in all WooCommerce versions. If you cannot find it, use Method 1 or Method 3.

Method 3: PHP Code Snippet (Precise Control)

This method disables cart fragments only on non-cart pages, leaving it fully active on the cart and checkout pages where it is actually needed.

add_action( 'wp_enqueue_scripts', function() {
    if ( ! is_cart() && ! is_checkout() ) {
        wp_dequeue_script( 'wc-cart-fragments' );
    }
}, 99 );

This tells WordPress: on any page that is not the cart or checkout, remove the cart fragments script before it loads.

Where to Add This Code

Option A: Theme functions.php

  1. Go to Appearance in your WordPress admin
  2. Click Theme File Editor
  3. Select functions.php from the file list on the right
  4. Scroll to the very bottom of the file
  5. Paste the code on a new line after the last line
  6. Click Update File

Before editing functions.php, create a backup of your site. A syntax error in this file makes your site go blank. If that happens, connect via FTP or your hosting file manager and delete the code you added.

If your theme has a child theme, add the code to the child theme’s functions.php instead. Changes to a child theme’s functions.php survive theme updates. Changes to the parent theme’s functions.php get overwritten when the theme updates.

Option C: Site-specific plugin

Create a small plugin to hold this code so it is not tied to your theme at all. Create a file called my-store-tweaks.php with this content:

<?php
/**
 * Plugin Name: My Store Tweaks
 * Description: Custom site modifications
 * Version: 1.0
 */

add_action( 'wp_enqueue_scripts', function() {
    if ( ! is_cart() && ! is_checkout() ) {
        wp_dequeue_script( 'wc-cart-fragments' );
    }
}, 99 );

Upload this file to your wp-content/plugins/ folder, then activate it from your WordPress plugins list.

When to use this method: You want precise control over which pages the fix applies to, or plan to expand the conditions later.

How to Verify It Worked

After applying any of the three methods, run this test to confirm cart fragments has been disabled.

  1. Open a product page or your homepage in your browser
  2. Right-click anywhere on the page
  3. Click Inspect or Inspect Element (the exact wording depends on your browser)
  4. Click the Network tab in the panel that opens
  5. Reload the page
  6. In the Network tab, look for a search or filter box and type: fragments
  7. If no results appear, the fix is working. The cart fragments request is no longer firing on this page.
  8. Now navigate to your cart page and repeat the check. The request should appear here because we kept cart fragments active on the cart.

If you still see the fragments request on non-cart pages, one of these is the cause:

  • Another plugin is re-enabling the script after your code removes it. Try increasing the priority in the PHP code from 99 to 999.
  • Your caching plugin has cached a version of the page from before the fix. Clear your cache and test again.
  • If you used Method 1, check that the plugin is activated, not just installed.

What Changes After You Disable It

The cart item count in your header will no longer update in real time on non-cart pages.

In practice this means: if a visitor adds a product to their cart from a product page, and then navigates to your homepage, the cart count in the header may still show the previous number. When they visit the cart or checkout page, it updates.

For most stores and most customers, this is not noticeable. Customers who add something to the cart typically proceed toward checkout, not away from it.

The cart count updating on the cart page itself is what matters.

If your store design relies on the cart count updating dynamically throughout the site as a key part of the shopping experience, test carefully before disabling. Most stores do not have this requirement.

When NOT to Disable Cart Fragments

Leave cart fragments enabled in these situations:

  • Your theme has custom JavaScript that depends on the cart fragments response to update elements beyond the simple cart count. Check with your theme developer if you are unsure.
  • You use a page builder like Elementor that has its own cart widget with real-time update behaviour. Test the widget after disabling to confirm it still works correctly.
  • Your store relies on mini-cart popups that display item details in real time on every page. These usually depend on cart fragments data.

If any of these apply, you can still use Method 3 and modify the condition. For example, to also keep cart fragments active on all product pages:

add_action( 'wp_enqueue_scripts', function() {
    if ( ! is_cart() && ! is_checkout() && ! is_product() ) {
        wp_dequeue_script( 'wc-cart-fragments' );
    }
}, 99 );

The Performance Impact

Disabling cart fragments removes one HTTP request from every non-cart page load. On a well-configured server, each HTTP request takes 50-200ms. On slower shared hosting, it can be significantly more.

The visible effect is most noticeable in three places:

  • Your GTmetrix or PageSpeed Insights waterfall shows one fewer request on every page
  • Pages load slightly faster for first-time visitors who have no cached version of the page
  • Caching configurations that were being bypassed by the dynamic cart fragments request can now fully cache affected pages

Cart fragments is one of several quick wins in the WooCommerce speed optimization guide.

On stores already running server-level caching from a managed host such as Kinsta, WP Engine, or Hostinger, the visible difference is smaller.

On stores where caching was being blocked by the dynamic request, the improvement is more noticeable.

FAQ’s

What is WooCommerce cart fragments?

WooCommerce cart fragments is a JavaScript feature that fires a background request on every page load to keep the cart count in the header updated in real time. It runs on all pages by default, including pages where no cart interaction is possible.

Will disabling cart fragments break my WooCommerce store?

No, for most stores. The cart and checkout pages continue to work normally. The only change is that the cart count in the header updates when visitors visit the cart page rather than updating in real time on every page. Test your checkout flow after disabling to confirm.

Does disabling cart fragments improve speed?

Yes. It removes one HTTP request from every non-cart page load and allows caching to work more efficiently on pages that were previously serving dynamic cart data. The improvement is measurable in GTmetrix and Google PageSpeed Insights waterfall views.

What is wc-ajax=get_refreshed_fragments?

This is the AJAX endpoint WooCommerce calls to retrieve updated cart data. When cart fragments is active, your browser sends a request to this URL on every page load. Disabling cart fragments stops this request from firing on non-cart pages.

Can I disable cart fragments without a plugin?

Yes. Use the PHP snippet in Method 3 of this guide. Add it to your child theme’s functions.php or create a small site-specific plugin to hold it. No additional plugin is needed.

Does this fix work with WP Rocket?

Yes. WP Rocket has its own cart fragments handling, but adding the PHP snippet or using the Disable Cart Fragments plugin works alongside WP Rocket without conflict. After applying the fix, clear your WP Rocket cache and retest.

Disabling cart fragments is one of the fastest wins available on any WooCommerce store. It takes under 10 minutes, costs nothing, and is reversible if anything looks wrong. For the full WooCommerce performance stack in the right order, the speed guide covers everything from hosting to CDN.