Skip to content
FunnelGuard

Fix guide by FunnelsGuard

WooCommerce cart fragments AJAX slowing your site: how to fix it

OPS-259Medium impactPartlyBy FunnelGuardPublished Updated
On this page

What this issue is

WooCommerce keeps a small piece of cart HTML, called a fragment, so the header cart icon and count can update without reloading the page. To do this, the script wc-cart-fragments.js sends an AJAX request (a background request to your server) to /?wc-ajax=get_refreshed_fragments. Older setups use admin-ajax.php instead.

Why it costs you leads or sales

Slow pages lose visitors before they reach a product or checkout. On shared hosting or a busy store, a burst of fragment requests can push up server response time (TTFB, the time before the first byte arrives) for everyone, including shoppers who are about to pay. It can also make the cart icon flicker or show a stale count.

How one page view turns into extra server work
  1. Visitor opens a pageServed quickly from cache
  2. Cart fragments script loadsRuns on every page
  3. get_refreshed_fragments callHits PHP and database, uncached
  4. Server queue growsTTFB rises under traffic
  5. Visitor leaves or hesitatesFewer carts and checkouts

The cached page is fast, but the fragment request bypasses the cache.

Server response time with and without fragmentsExample numbers
Server response time with and without fragments (example)Cached page: 200 ms; Fragments request, quiet hour: 600 ms; Fragments request, peak hour: 1,800 ms06901,3802006001,800Cached pageFragments request, qu…Fragments request, pe…ms

Example: illustrative response times on a busy shared host, not measured data.

How to check if your site has it

Confirm the request is running
  1. Open DevTools

    In Chrome, press F12 and go to the Network tab. Tick Disable cache and reload a page in a private window.

  2. Filter for the request

    Type get_refreshed_fragments or wc-ajax in the filter box. If you see a request, the script is active.

  3. Read its timing

    Click the request and open Timing. A Waiting (TTFB) value of several hundred milliseconds or more on an empty cart is a sign of waste.

  4. Check the script

    Search the page source for wc-cart-fragments to see whether the script is enqueued.

  5. Check your host

    Look at the access logs or your host's monitoring for many wc-ajax=get_refreshed_fragments hits compared with page views.

How to fix it

Decide first whether your theme needs a live mini cart. If the cart icon shows a count or a dropdown, you need fragments on those pages. If it is just a link to the cart page, you can remove the script. Always test on a staging copy, then check add to cart and checkout.

Limit or disable cart fragments
  1. Use a performance plugin option

    Plugins such as Perfmatters or Disable Cart Fragments offer a toggle to disable cart fragments. Many let you disable it everywhere except the cart and checkout. Check your plugin's settings for the exact name.

  2. Or add code to a child theme

    Use the snippet below in your child theme's functions.php or a code snippets plugin. Back up first.

Dequeue cart fragments except on cart, checkout and account pagesphp
add_action( 'wp_enqueue_scripts', function () {
    if ( function_exists( 'is_cart' ) && ( is_cart() || is_checkout() || is_account_page() ) ) {
        return;
    }
    wp_dequeue_script( 'wc-cart-fragments' );
}, 11 );

How to confirm it's fixed

After the change
  • The get_refreshed_fragments request no longer appears on product and content pages
  • TTFB on key pages is the same or lower than before
  • Adding a product still updates the cart page and checkout totals
  • The header cart count is correct where it is shown
  • Checkout completes a test order in test mode
  • Purchase and add to cart tracking events still fire

How to prevent it happening again

Themes and plugin updates can re-enqueue the script. Keep your dequeue code in a child theme or a small plugin so it survives updates. Re-check the Network tab after major theme, WooCommerce or caching changes, and keep an eye on TTFB over time.

How FunnelGuard handles this

FunnelGuard detects this issue only partly. A robot visitor loads your pages on a schedule and checks TTFB and page weight. A rise in either can be a symptom of heavy cart fragment traffic, so you get an alert with a screenshot and a likely cause.

What it does not do: it does not confirm that wc-cart-fragments.js or the get_refreshed_fragments request is the cause, and it does not inspect your server logs or plugin settings. To cover the rest by hand, use the Network tab check above, review host logs, and test the header cart after each theme or plugin update. The Free plan (1 site, 2 journeys, daily checks, no card) lets you start watching your add to cart journey.

Questions people ask

What are WooCommerce cart fragments?

Cart fragments are small pieces of cart HTML that WooCommerce refreshes through an AJAX request so the mini cart stays current. The script wc-cart-fragments.js calls ?wc-ajax=get_refreshed_fragments on page load. It is useful for a live header cart but costly on busy sites.

Why is my WooCommerce site slow with wc-ajax=get_refreshed_fragments?

That request is dynamic, so page caches and CDNs usually cannot serve it. Each page view can run PHP and database queries, which raises TTFB under traffic. Slow hosting makes the effect worse.

How do I disable cart fragments in WooCommerce?

Dequeue the wc-cart-fragments script with wp_dequeue_script in a child theme, or use a performance plugin that has a disable option. Keep it on the cart and checkout pages if your theme needs it there. Test add to cart afterwards.

Is it safe to disable cart fragments?

It is safe if your theme does not show a live cart count or dropdown. If it does, the count may stay stale after adding a product. Test on staging and keep the script on pages that need it.

Does disabling cart fragments break checkout?

Normally no, because the cart and checkout pages render their own totals. Problems appear only if a theme relies on fragments for the mini cart. Run a test order after the change.

How can I see if cart fragments is slowing my pages?

Open DevTools, go to Network, disable cache and filter for get_refreshed_fragments. Check the Waiting time on an empty cart. Compare TTFB on pages with the script removed.

Can FunnelGuard detect cart fragments problems?

Only partly. It checks TTFB and page weight on scheduled runs and alerts you if they worsen, but it does not identify the cart fragments request itself as the cause. You confirm that by hand.

Does FunnelGuard catch this?

Partly

FunnelGuard checks part of this.

How: TTFB/page weight.

Stop finding out from your customers

FunnelGuard runs your real forms and checkouts on a schedule, checks the tracking and the leads behind them, and alerts you once, with a screenshot. Try any paid plan free for 3 days.