Fix Slow Page Loading with WooCommerce wc-ajax=get_refreshed_fragments

Some people when they did a page speed check on Gtmetrix, they found the component “wc-ajax=get_refreshed_fragments” takes 5 to 10 seconds for the page to load.

Disable Cart Fragmentation on Front Page

Add the following code at the end of your theme functions.php file.

/** Disable Ajax Call from WooCommerce */
add_action( ‘wp_enqueue_scripts’, ‘dequeue_woocommerce_cart_fragments’, 11);
function dequeue_woocommerce_cart_fragments() { if (is_front_page()) wp_dequeue_script(‘wc-cart-fragments’); }

Then navigate to “WooCommerce > Settings” menu and go to the “Products”tab. Enable the checkbox against the option “Redirect to the cart page after successful addition”.