Disable Cart Fragments

Description

Completely disables the AJAX cart fragments feature in WooCommerce for a huge boost in loading speed (redirect to cart page highly recommended).

The Long Version

Disable Cart Fragments is a simple plugin that disables the AJAX ‘cart fragments’ feature in WooCommerce. That feature automatically updates the cart total in your shopping cart without having to refresh the page. The problem with this is that is severely slows down many WooCommerce websites especially on shared hosting servers. Plus, the feature isn’t even used in many cases. We recommend that if you install this plugin, you either disable it selectively on certain pages (see the Installation tab) or if installing as one-click then make sure you enable ‘redirect to cart page’ option in WooCommerce settings so that when a customer adds a product to their Cart, it redirects to the Cart page automatically so as to not confuse them about what happened to their chosen product.

This plugin removes e.g.

/* <![CDATA[ */
var wc_cart_fragments_params = {"ajax_url":"\/wp-admin\/admin-ajax.php","wc_ajax_url":"\/about?wc-ajax=%%endpoint%%","fragment_name":"wc_fragments"};
/* ]]> */
</script>
<script type='text/javascript' src='//example.com/wp-content/plugins/woocommerce/assets/js/frontend/cart-fragments.min.js'></script>

You can selectively disable using a defined constant:

define('DISABLE_CART_FRAGMENTS', '123,456,789');

For initial release we’ve implemented via dequeue rather than print scripts, will review based on feedback.

Compatibility

This plugin has been designed for use on LEMP (Nginx) web servers with PHP 7.0 and MySQL 5.7 to achieve best performance. All of our plugins are meant for single site WordPress installations only; for both performance and security reasons, we highly recommend against using WordPress Multisite for the vast majority of projects.

Plugin Features

  • Settings Page: No
  • Premium Version Available: Yes (Speed Demon)
  • Includes Media (Images, Icons, Etc): No
  • Includes CSS: No
  • Database Storage: Yes
    • Transients: No
    • Options: Yes
    • Creates New Tables: No
  • Database Queries: Backend Only (Options API)
  • Must-Use Support: Yes (Use With Autoloader)
  • Multisite Support: No
  • Uninstalls Data: Yes

WP Admin Notices

This plugin generates multiple Admin Notices in the WP Admin dashboard. The first is a notice that fires during plugin activation which recommends several related free plugins that we believe will enhance this plugin’s features; this notice will re-appear approximately once every 6 months as our code and recommendations evolve. The second is a notice that fires a few days after plugin activation which asks for a 5-star rating of this plugin on its WordPress.org profile page. This notice will re-appear approximately once every 9 months. These notices can be dismissed by clicking the (x) symbol in the upper right of the notice box. These notices may annoy or confuse certain users, but are appreciated by the majority of our userbase, who understand that these notices support our free contributions to the WordPress community while providing valuable (free) recommendations for optimizing their website.

If you feel that these notices are too annoying, than we encourage you to consider one or more of our upcoming premium plugins that combine several free plugin features into a single control panel, or even consider developing your own plugins for WordPress, if supporting free plugin authors is too frustrating for you. A final alternative would be to place the defined constant mentioned below inside of your wp-config.php file to manually hide this plugin’s nag notices:

define('DISABLE_NAG_NOTICES', true);

Note: This defined constant will only affect the notices mentioned above, and will not affect any other notices generated by this plugin or other plugins, such as one-time notices that communicate with admin-level users.

Code Inspiration

This plugin was partially inspired either in “code or concept” by the open-source software and discussions mentioned below:

Recommended Plugins

We invite you to check out a few other related free plugins that our team has also produced that you may find especially useful:

Premium Plugins

We invite you to check out a few premium plugins that our team has also produced that you may find especially useful:

Special Thanks

We thank the following groups for their generous contributions to the WordPress community which have particularly benefited us in developing our own free plugins and paid services:

Disclaimer

We released this plugin in response to our managed hosting clients asking for better access to their server, and our primary goal will remain supporting that purpose. Although we are 100% open to fielding requests from the WordPress community, we kindly ask that you keep the above mentioned goals in mind, thanks!

Installation

  1. Upload to /wp-content/plugins/disable-cart-fragments-littlebizzy
  2. Activate via WP Admin > Plugins
  3. Test the plugin by refreshing pages and checking source code after clearing caches
  4. To disable cart fragments on specific posts/pages (using their ID), refer to below defined constant:

    define(‘DISABLE_CART_FRAGMENTS’, ‘123,456,789’);

FAQ

Installation Instructions
  1. Upload to /wp-content/plugins/disable-cart-fragments-littlebizzy
  2. Activate via WP Admin > Plugins
  3. Test the plugin by refreshing pages and checking source code after clearing caches
  4. To disable cart fragments on specific posts/pages (using their ID), refer to below defined constant:

    define(‘DISABLE_CART_FRAGMENTS’, ‘123,456,789’);

Does this plugin disable my WooCommerce shopping cart?

Nope, it only disables AJAX features of add-to-cart. Refreshing the page will still show cart totals.

Are there other recommendations to keep in mind?

Yes, you should enable redirect to cart page in WooCommerce settings to ensure customers aren’t confused. This will make sure that after adding an item to their Cart, they are automatically redirected to the Cart page each time. You should also disable AJAX add to cart on archives page because this plugin disables that AJAX site-wide by default.

How can I change this plugin’s settings?

This plugin does not have a settings page and is designed for speed and simplicity.

I have a suggestion, how can I let you know?

Please avoid leaving negative reviews in order to get a feature implemented. Instead, we kindly ask that you post your feedback on the wordpress.org support forums by tagging this plugin in your post. If needed, you may also contact our homepage.

Reviews

Great plugin thank you so much!

I would gladly pay you guys for this plugin to keep it updated because the only other real option is a developer but this is better because you guys update the code as needed when woocommerce updates. To get a developer to constantly update their code is expensive. The woocommerce’s js file would take anywhere from (.3 to 2 seconds) to load on every page; now it’s zero! & my site loads on average of 1.2-1.3 seconds in most good servers/locations around the world; & on some servers I’ve gotten well below a second consistently:
[ link redacted ]

Finally Two A’s on GTMetrix!

I have been tweaking my site performance for years, finely tuning the balance between adding functionality with plugins, and keeping my photography heavy site as nimble as possible. After adding the Disable Cart Fragments plugin last week I finally got two A scores for PageSpeed and YSlow on GTMetrix. Of course, it’s a combination of caching with WP Rocket and Cloudflare, but Disable Cart Fragments was the key that finally unlocked the double-A. Thank you!

It Works for my site! Does what it says

It Works! Does what it says, This plugin disables the AJAX ‘cart fragments’ feature in WooCommerce. Makes my site become faster and reduce usage of CPU & RAM resources from my shared hosting. Amazing Plugin! Good Job, many thanks to Dev. (LitteBizzy) 🙂

Read all 11 reviews

Contributors & Developers

“Disable Cart Fragments” is open source software. The following people have contributed to this plugin.

Contributors

Changelog

1.0.9

  • added warning for Multisite installations
  • updated recommended plugins

1.0.8

  • tested with WP 4.9
  • added support for define('DISABLE_NAG_NOTICES', true);

1.0.7

  • optimized plugin code
  • updated recommended plugins
  • added rating request

1.0.6

  • minor code tweaks
  • updated recommended plugins

1.0.5

  • updated recommended plugins

1.0.4

  • added recommended plugin notices

1.0.3

  • tested with WP 4.8

1.0.2

  • updated plugin meta

1.0.1

  • updated plugin meta

1.0.0

  • initial release