Skip to content

Dequeue WooCommerce Cart Fragments

Milan Petrovic edited this page Oct 2, 2020 · 1 revision

Dequeue WooCommerce Cart Fragments

If you use WooCommerce, you know that it runs an AJAX call on every page load to get changes for the Cart. That is done always, regardless of the need for it, and in most cases, it is not needed and should be disabled. That can't be fully done through WooCommerce settings, but the script to do it is quite simple. If you want to learn more about WooCommerce Cart Fragments, there are plenty of resources on the internet.

Make sure you understand what the Cart Fragments are, and if you really need them or not, and use this code accordingly!

How this plugin works

It is quite simple, it will dequeue WooCommerce wc-cart-fragments script on all WordPress pages, except on product archives and single product pages. Line 20 controls the conditions for this removal, and you can modify it if needed.