What Are Ajax Cart Fragments and Why Do They Slow Your Site Down?
Ajax Cart Fragments is a JavaScript function WooCommerce uses to update the cart contents (number of items, total amount) on every page load. Even when the page content is served from cache, this function sends a new request to the server to fetch up-to-date cart data.
- The
wc-ajax=get_refreshed_fragmentsrequest fires on every page load. - This request reloads the WordPress core and the WooCommerce plugin every time.
- It bypasses caching mechanisms and ties up the server’s CPU directly.
On the server side, this creates serious bottlenecks, especially as traffic grows. Every visitor, whether or not they have items in their cart, sends a heavy PHP request to the server on every page view. By today’s web standards, unnecessary background processes like this are among the biggest factors dragging down Core Web Vitals scores. No matter how powerful your server is, this mechanism, triggered on every page load, ends up limiting how many users you can serve at the same time.
Technically, this process creates a load similar to how the admin-ajax.php file works. In the browser, it ties up the JavaScript main thread and delays the user’s ability to interact with the page. On low-end mobile devices in particular, this delay shows up as micro-stutters that make users leave the page. That’s why loading cart data only when it’s needed, or by other methods, is a modern necessity.
On the database side, this function constantly sends queries to the wp_options or wp_woocommerce_sessions tables to check cart session data. If your site has thousands of active sessions, these queries can cause database locks or slowdowns. Disabling Ajax Fragments takes a heavy load off both the CPU and the database engine, improving overall site stability.
| Performance metric | Ajax Fragments Enabled | Ajax Fragments Disabled | Improvement | UX impact |
|---|---|---|---|---|
| Server Response Time (TTFB) | 950ms | 210ms | %77 | Very high |
| Total Page Size | 1.4 MB | 1.1 MB | %21 | Medium |
| CPU Load | High (80%+) | Low (20%) | %75 | Critical |
| Time to Interactive | 3.4 s | 1.8 s | %47 | High |
| Number of Database Queries | 45 queries | 12 queries | %73 | High |
Disabling Ajax Cart Fragments with Code
The cleanest and most efficient way to disable this feature is a short code snippet added to your theme’s functions.php file. This method lets you intervene directly at the system level without installing an extra plugin.
- The
wp_dequeue_scriptfunction prevents the related JavaScript file from loading. - WooCommerce’s cart refresh hooks are deactivated.
- You can restrict it to specific areas only, such as the homepage or product pages.
The most important thing to keep in mind when adding the code block is that cart updates will no longer be automatic. When a user adds a product to the cart, the page may need to reload or the user may need to be redirected to the cart page. In current e-commerce trends, redirecting straight to checkout after “Add to Cart” both increases conversion rates and removes this technical load. This code-level change optimizes your site’s resource consumption instantly.
To implement it, simply hook into the woocommerce_enqueue_scripts action and dequeue the wc-cart-fragments script. Once you do this, you’ll notice that get_refreshed_fragments requests no longer appear in the browser console. This means an extra PHP cycle no longer runs for every page visit to your server. Advanced users can make the code conditional, running it only for users with an empty cart, to create a more hybrid solution.
Keep in mind, however, that with this method the number on your theme’s cart icon may not update. If you use a dynamic cart counter, you can update it with the lighter JavaScript localStorage method instead. That way, you can keep showing the cart count using data stored in the browser, without contacting the server. This approach matches exactly how modern web applications (PWAs) work.
On Which Pages Should You Disable It?
This feature doesn’t need to run on every page, so a strategic restriction is the most sensible approach.
- It should be turned off completely on blog posts and content pages.
- There’s no need to load it on About, Contact and corporate pages.
- On the homepage, it should be disabled unless there’s significant cart interaction there.
Optimizing with the Top 5 Performance Plugins
If you’d rather not deal with code, there are professional tools that do this in one click and offer additional optimizations. These plugins don’t just disable Ajax Fragments; they also improve your site’s overall speed scores.
- Perfmatters: The lightest tool for script management and disabling Ajax Fragments.
- Asset CleanUp: Removes unnecessary assets with per-page script control.
- WP Rocket: Offers script delay options alongside caching.
- Clearfy: Optimizes WordPress bloat and Ajax overhead.
- FlyingPress: Optimizes cart interactions using modern web technologies.
Among these tools, Perfmatters stands out with its “Script Manager,” which lets you choose which scripts run on which pages through a visual interface. For example, you can keep Ajax Cart Fragments active only on single product pages and disable it across the rest of the site. This preserves the user experience while still delivering performance gains. In today’s complex web setups, granular controls like this have become very important.
When using plugins, the key is to avoid conflicts. If you use a caching plugin, make sure the option to disable Ajax Fragments is enabled in only one place. When several plugins try to block the same script, it can sometimes lead to JavaScript errors. So after optimizing, it’s a good idea to check the browser console (F12) for any “404 Not Found” or “Uncaught ReferenceError” errors.
It’s critical that the plugin you choose is up to date and compatible with the latest versions of WooCommerce. Plugin developers have started making these heavy Ajax requests lighter by using the modern Fetch API. If your plugin supports this kind of modernization, you can also consider a “Delay Loading” option instead of disabling the feature completely.
Source: WordPress Plugin Repository
Related serviceWordPress Site Optimization ↗Redirect Strategies for the Cart Page
When you disable Ajax Cart Fragments, the most effective way to protect the user experience is to change how the “Add to Cart” button behaves. Instead of waiting for the page to update itself when a product is added, sending the user straight to the next step also has a positive effect on sales conversions.
- In the WooCommerce settings, enable “Redirect to the cart page after successful addition.”
- Uncheck “Enable AJAX add to cart buttons on archives.”
- Use a modern “mini cart” popup that opens after a product is added.
This strategy moves the technical load away from the server and focuses on the user flow. If the page reloads when a user adds a product, all cart data already arrives up to date from PHP, so the Ajax request is no longer needed. In today’s e-commerce ecosystem, “quick buy” buttons and direct checkout transitions are replacing complex Ajax setups. With this method, you solve a technical problem and shorten the purchase journey at the same time.
With a cart redirect, the server-side load is also limited to a single page load. Because no mechanism is constantly running in the background and polling the server every second, even shared hosting users can see their sites stay up on high-traffic days. This simple settings change is one of the most basic measures to prevent server crashes, especially during sales campaigns.
From a customer psychology perspective, a clear page redirect confirming that the product was added is more reassuring than a small loading icon spinning in the background. The user is sure the action went through and moves on to checkout. This is a psychological trigger that lowers cart abandonment rates. This is where technical optimization meets marketing strategy, and it directly affects your site’s success.
Making Caching Plugins Work Seamlessly
Once Ajax Fragments is disabled, caching plugins (WP Rocket, LiteSpeed Cache, W3 Total Cache) become dramatically more efficient. That’s because caching systems usually can’t cache dynamic Ajax requests and let them through to the server every time.
- Static pages are served from cache in milliseconds.
- Server-level caches in Nginx or Apache are bypassed less often.
- A CDN (Cloudflare, BunnyCDN) becomes more effective because there are fewer dynamic queries.
If you use a LiteSpeed server, you can use “ESI” (Edge Side Includes) technology after disabling Ajax Fragments. ESI lets you serve most of the page statically while loading only small areas, such as the cart, dynamically. However, disabling Ajax Fragments completely delivers even faster results than an ESI setup. In server-side optimization, aiming for “zero dynamic requests” is something the fastest sites have in common.
In popular plugins like WP Rocket, you can push Ajax Fragments scripts to the end of the queue with the “Delay JavaScript execution” feature. However, this only lightens the load in the browser; the PHP load on the server remains. That’s why the real fix is to make sure these scripts never load at all. If your caching plugin’s settings include an option such as “Disable WooCommerce cart fragments,” be sure to enable it.
In your caching strategy, always exclude the cart, checkout and My Account pages. These pages are personal by nature and should never be cached, even with Ajax Fragments turned off. On all other product, category and blog pages, disabling Ajax Fragments lets your server focus only on the dynamic processes that are truly needed.
Impact on Mobile Performance and Core Web Vitals
In Google’s current search algorithm, mobile user experience and speed metrics (LCP, INP, CLS) are top-priority ranking factors. Ajax Cart Fragments has a particularly negative effect on the INP (Interaction to Next Paint) metric.
- Scripts running in the background after the page loads delay the response to the user’s first tap.
- Ajax loops that keep the CPU busy can increase battery drain and heat on mobile devices.
- Unnecessary network requests make the page feel “frozen” to mobile users on slow connections.
Mobile devices have more limited processing power than desktop computers. A 500ms Ajax request that goes unnoticed in a desktop browser can turn into a 2-second delay on a mid-range Android phone. When Ajax Fragments is disabled, the JavaScript main thread is freed up, and users get an instant response when they scroll or tap a menu. This gives a direct boost to Google’s user experience assessment.
Largest Contentful Paint (LCP) is also indirectly affected by this optimization. Because the server isn’t busy answering unnecessary Ajax requests, it delivers the actual page content (images, text) to the browser much faster. This helps your site be seen as “fast and reliable” in Google’s eyes. Modern SEO is no longer just about keywords; it’s also made up of micro-level technical optimizations like this.
Cumulative Layout Shift (CLS) issues can also sometimes be triggered by cart fragments loading late. When the cart icon or count loads afterward, the page layout can shift. Turning off this feature and switching to a static structure keeps the layout stable from the moment the page loads, giving users a more professional interface.
Increasing Mobile Conversion Rates
As speed and user experience improve, you’ll typically see a noticeable increase in orders from mobile devices.
- Fast-loading product pages keep users on your site longer.
- A smooth interface gives users more confidence as they move to checkout.
- Pages that use less data are an advantage for users with limited mobile data plans.
Testing and Monitoring After Speed Optimization
After disabling Ajax Fragments, it’s vital to measure the impact of your changes on performance and to check that the site still works properly. You don’t want to focus only on speed and break the buying process.
- Compare your mobile and desktop scores in Google PageSpeed Insights.
- Confirm in GTmetrix’s “Waterfall” tab that the
get_refreshed_fragmentsrequest is gone. - Test adding products to the cart in different browsers (Chrome, Safari, Firefox).
During testing, make sure the cart doesn’t empty, products are added correctly and the total appears correctly on the checkout page. If you use a “Side Cart” plugin, it may have its own Ajax mechanism. In that case, disabling WooCommerce’s standard fragments feature won’t cause any problems; on the contrary, it can prevent conflicts. Data-driven optimization has overtaken improvements based on guesswork.
You can also review your server logs (access logs) to see the drop in requests containing admin-ajax.php or wc-ajax. This drop lets you lower your server costs or handle more traffic with your current server. With performance monitoring tools (New Relic, Query Monitor), you can report in concrete numbers how much the load on your database has decreased.
Finally, keep an eye on user feedback. If customers complain that “I can’t add products to the cart” or “my cart isn’t updating,” you may need to review your code change or plugin settings. With the right redirect strategy (such as redirecting after add to cart), though, you can reach maximum speed without running into any of these problems.
Source: web.dev Core Web Vitals guide
Frequently Asked Questions
Will disabling Ajax Fragments break my cart?
No. It only stops the cart from updating in the background without a page reload. If the page reloads after adding to cart, or the user goes to the cart page, products appear as usual.
Which plugin is best for this?
Thanks to its light footprint and detailed controls, Perfmatters is the tool professionals choose most often. If you’re looking for a free alternative, a simple code snippet will do the same job.
Why does my cart counter show zero after adding the code?
Because when Ajax Fragments is disabled, the browser doesn’t fetch new data from the server. To fix this, enable the redirect after adding to cart or use the JavaScript LocalStorage method.
Will this affect my SEO score?
Yes. Because it directly improves page speed (TTFB and LCP), it has a positive effect on your search engine rankings. Google rewards e-commerce sites that respond faster.
Should this feature be disabled on every WooCommerce site?
If your server response time is over 1 second and you have thousands of products, disabling it is strongly recommended. On very low-traffic sites with very powerful servers, though, the effect may be less noticeable.
In short
In this guide, we covered the server load caused by Ajax Cart Fragments and the technical ways to minimize it. With the right optimization strategy, you can bring your WooCommerce site’s speed up to current standards and take the user experience to a new level.
















