How to Disable Cart Fragments in WooCommerce?
Ahsan Parwez
HostWP Expert
You can disable WooCommerce cart fragments by dequeuing the wc-add-to-cart script, which stops the get_refreshed_fragments AJAX call from firing on every page load. You can do this with a simple code snippet in your theme’s functions.php, or by using a dedicated plugin that loads cart fragments only on shop, cart, and checkout pages.
Detailed Answer
- Disabling cart fragments prevents WooCommerce from making an uncached background request on every page view. Here is how to do it:
- Use a code snippet: Add a small function to your child theme’s functions.php that deregisters the cart fragments script globally. This removes the AJAX call entirely.
- Load conditionally instead: A better approach is to disable fragments on non-shop pages (blog, homepage, about) while keeping them active on shop, cart, and checkout pages. This keeps the live cart update where it matters.
- Use a plugin: If you prefer not to touch code, install a lightweight plugin designed to conditionally load cart fragments. Avoid heavy “speed” plugins that add more scripts of their own.
- Test after disabling: Confirm your header cart still updates correctly on the shop page. If it does not refresh, your theme relies on fragments, and you should switch to conditional loading rather than full removal.
Before you disable cart fragments, understand that the feature itself is not the enemy β loading it everywhere is. A store that fully removes fragments loses the live cart counter, which can hurt user experience. The smarter move is conditional loading, which keeps the dynamic update on selling pages while letting your cache work freely on content pages. At HostWP.io, our LiteSpeed servers handle the remaining dynamic requests quickly, so combining conditional fragments with proper caching gives you both speed and a smooth shopping experience. Disable smart, not blind.
Our WordPress expert are here to help you 24/7.
On this page
Related Questions
Expert WordPress Support Engineers Available 24/7
90 sec
Average
Response Time
98Β %
Customer
Rating
24/7
Expert
Support

