WooCommerce can use cart fragments to update the mini cart automatically. If your website doesn’t need this feature, disabling it can reduce unnecessary AJAX requests and improve page performance.
Steps
- Open your theme’s
functions.phpfile. - Add the code below.
- Save the file.
- Clear your website cache and test the cart.
Done — the WooCommerce cart fragments script will no longer load on the frontend.
function disable_woocommerce_cart_fragments() {
wp_dequeue_script( 'wc-cart-fragments' );
}
add_action(
'wp_enqueue_scripts',
'disable_woocommerce_cart_fragments',
100
);