Why (and How to) Disable Woocommerce Fragments

Woocommerce fragments

“What are Woocommerce fragments? Do I really need them?” 

The far too short answer is: they can help if you have a “shopping cart.” Otherwise, they could be slowing you down. 

Woocommerce is more popular than ever. Odds are that your business uses it. If not, your competitors probably do. 

As powerful and potent as it can be, it, like so much else, is really just a tool. If you don’t use the tool properly, then you aren’t going to get as much out of it. 

Knowing when to turn these fragments on and when to get rid of them can help quite a bit. 

Woocommerce fragments

 

Basics Woocommerce Fragments 

 

You might have already seen these fragments already and not realized it. You may have referred to them as “Ajax.” That’s not the name of a cartoon hero, rather, it’s an acronym for “Asynchronous JavaScript And XML.” 

All that means is that you won’t have to refresh website pages to run functions. 

In terms of Woocommerce, this typically comes into play with the Cart. 

On the Woocommerce Shop page, “Ajax Add to Cart” means that you can update the cart without having to reload. That kind of action is referred to as something that’s (all together now) “asynchronous.” 

So, you might ask at this point, “if Ajax and these fragments or whatever run my shopping cart, why would I ever want to disable them?” 

The answer is: yes. 

That’s because on some pages if you’re dealing with a lot of engagement, these fragments may actually slow your page down. 

Something important to keep in mind about these fragments: for the most part, Woocommerce runs Ajax functionality on every page. 

So, they’ll run on the pages you want them to run, the pages with products/services that your customers can buy. 

They’ll also run on your “Contact Us” page, the “About Us” page, and plenty of other pages where there are no products. At best, on those pages, they can be useless. At worst, they can slow everything down. That’s the last thing you want. 

To use an analogy, it’s like towing a trailer behind your car. If you’re going to use it, it’s great to have. If not, it’ll slow you down.

Woocommerce fragments

 

Disabling Fragments in Woocommerce 

For the most part, if you’re getting high traffic, you’re probably going to want to disable these fragments. While this may seem like it’s very difficult, as far as coding goes, it’s not all that bad. 

If you find the function “register_scripts()”, you’ll note that it describes the script “wc-cart-fragments.” 

That’s what we’re looking for. 

If JQuery and cookies are enabled, “register_scripts()” calls a JS script from the /assets folder. In this same file, you’ll note that “wc-cart-fragments” is called: 

“self:: enqueue_script (‘wc-cart-fragments’ );

There it is. 

What’s the opposite of “enqueue?” 

Right. 

It’s “dequeue.” 

Instead of “enqueuing” it, you’re “dequeuing” it. Instead of leaving it so that it can turn on, you’re turning it off. 

This doesn’t mean that your cart is going to disappear. Instead, it means that if you hover you won’t see cart/checkout buttons, the items in it, etc. 

Disabling these fragments might make your site only a little bit faster. But, that can make all the difference in the world between converting someone into a customer or losing them. 

For more help with growing your business, you can reach us at (888) 477-9540. 

 

No Comments

Be the first to start a conversation