Fix wc-ajax = get_refreshed_fragments High CPU Usage (Disable AJAX Cart Fragments)

A fairly common problem on online stores with WooCommerce is the excessive loading of the processor with the AJAX requests of the shopping basket. Fix wc-ajax = get_refreshed_fragments High CPU Usage.

Excessive loading of CPU processes of any present script, does nothing but to decrease the speed of loading online store pages, to bring a low SEO score and user experience. Fewer orders on the site.

What is and what uses the interrogation to WC-AJAX = Get_Refreshed_Fragments

On the meaning of all, with the help of this Ajax script, WooCommerce allow Adding products to the basket and updating shopping basket without the web page to refresh. The shopping cart will communicate asynchronous with the host server through AJAX (Asynchronous JavaScript and XML).

Fix wc-ajax = get_refreshed_fragments  High CPU Usage
AJAX Add to Cart

Predetermined, /?wc-ajax=get_refreshed_fragments is present in all pages of the site to track the actions Add to Cart of the user and the changes that can occur in the shopping cart widget. These actions are the ones that put processes on the CPU and slow down the speed of loading the web pages. Sometimes 4-5 seconds, which is very much.

Fix wc-ajax = get_refreshed_fragments High CPU Usage (Disable AJAX Cart Fragments)

If you do not use a dynamic widget of the shopping basket in the header or in another permanent area of the store, it is best to give up the dynamic update and to track the actions of adding / updating the basket.

You can disable AJAX Cart Fragments On the archive pages and redirect the users directly to the shopping cart when a product is added to the basket.

WooCommerce → Settings → Products.

Disable Add to Cart AJAX
Disable Add to Cart AJAX

If you want to leave this script activated “Add to Cart Ajax“, but do not run on the first page of the store, edit the functions.php file of the current theme and add the following code:

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'); }

In the scenario in which besides the WooCommerce pages you have a blog or other personalized pages that are not produced, a good idea is to deactivate the fragments of them.

add_action ('wp_enqueue_scripts', 'dequeue_woocommerce_cart_fragments', 11);
function dequeue_woocommerce_cart_fragments () {
if (is_front_page () || is_single ()) wp_dequeue_script ('wc-cart-fragments');
}

Total disabling and fix wc-ajax = get_refreshed_fragments High CPU Usage (Disable AJAX Cart Fragments) is done with the following code:

add_action ('wp_enqueue_scripts', 'dequeue_woocommerce_styles_scripts', 99);
function dequeue_woocommerce_styles_scripts () {
if (function_exists ('is_woocommerce')) {
if (! is_woocommerce () &&! is_cart () &&! is_account_page () &&! is_checkout ()) {
# Styles
wp_dequeue_style ('woocommerce-general');
wp_dequeue_style ('woocommerce-layout');
wp_dequeue_style ('woocommerce-smallscreen');
wp_dequeue_style ('woocommerce_frontend_styles');
wp_dequeue_style ('woocommerce_fancybox_styles');
wp_dequeue_style ('woocommerce_chosen_styles');
wp_dequeue_style ('woocommerce_prettyPhoto_css');
# Scripts
wp_dequeue_script ('wc_price_slider');
wp_dequeue_script ('wc-single-product');
wp_dequeue_script ('wc-add-to-cart');
wp_dequeue_script ('wc-cart-fragments');
wp_dequeue_script ('wc-checkout');
wp_dequeue_script ('wc-add-to-cart-variation');
wp_dequeue_script ('wc-single-product');
wp_dequeue_script ('wc-cart');
wp_dequeue_script ('wc-chosen');
wp_dequeue_script ('woocommerce');
wp_dequeue_script ('prettyPhoto');
wp_dequeue_script ('prettyPhoto-init');
wp_dequeue_script ('jquery-blockui');
wp_dequeue_script ('jquery-placeholder');
wp_dequeue_script ('fancybox');
wp_dequeue_script ('jqueryui');
}
}
}

After choosing one of these methods (especially the last) you will immediately notice an increase in the speed of loading the online store and a much lower consumption of resources on the processor (CPU).

Passionate about technology, I write with pleasure on stealthsetts.com starting with 2006. I have a rich experience in operating systems: Macos, Windows and Linux, but also in programming languages ​​and blogging platforms (WordPress) and for online stores (WooCommerce, Magento, Presashop).

Home Your source of IT tutorials, useful tips and news. Fix wc-ajax = get_refreshed_fragments High CPU Usage (Disable AJAX Cart Fragments)
Leave a Comment