WooCommerce is a powerful e-commerce platform with an extensive list of features that allow you to customize your store. However, it can be hard to manage all those options and keep track of which scripts are loading where. This post will show you how to optimize WooCommerce by stopping scripts from loading on pages where they're not needed.
WooCommerce comes with a lot of scripts that are designed to run automatically on all pages. These include: wc-loggedin, addtocart, cart_redirect and _wc_additional_scripts. With the other scripts running in the background it’s not always obvious which ones affect page load time because they're scattered across various pages and WordPress templates. The following code snippet will help you optimize your store by stopping unnecessary scripts from loading on pages where they're not used.
You can use AssetCleanup to stop WooCommerce scripts from loading too. This plugin can be a great help to WooCommerce store owners who want their website to load faster. This plugin can help you optimize your WooCommerce scripts by "unloading" various scripts via a GUI or regex rules.
Just to be clear, this plugin doesn't actually remove the scripts from your site. It just stops them from loading on every pageview of a customer's browser window when they enter their store. And that can make a huge difference to your customers' experience with your website, and in turn it makes you look better too!
This is one of those plugins where if you're not sure whether or not it will work for you then give it a try because there really isn't any way to lose here. The worst thing that could happen is nothing, but the best-case scenario is that everything works even more smoothly than before without having additional code slowing down load times and bogging things down on mobile devices.