When you first launch your Magento2 development store, everything is fast. But over time, things change. You notice how your homepage is not as snappy as before, that your search lags too much, and – oh dear! – your Add to Cart, the very reason you created the store, is so slow no-one wants to buy anything anymore.
What are the reasons why your Magento Add to Cart is very slow? In addition to our in-depth guide where we give more detail for every possible challenge, we would like to list the top reasons Add to Cart can be slow in Magento. So here comes.
Reason 1. You Have Too Many Pricing Rules
Adding new stuff to Magento can be a double-edged sword. When you add new rules or parameters to the Cart, the process becomes a little bit slower every time.
After a while, the slowdowns become noticeable. Look at the most common additions that can ruin your add to cart performance: “Get two items for the price of one.” “Apply 15% off on a specific date.” “Save more with this promotion!” – every new active price rule creates a condition inside Magento and the platform has to check this new condition whenever the user adds new stuff to their shopping cart.
Does this item get a discount? Is this bundle eligible for that promotion? Will this many products in the cart apply a cumulative price cut?
Go to Marketing > Cart Price Rules to disable outdated Cart Rules
We understand that creating deals inside your store is an inseparable part of online retail. We don’t say you should avoid pricing rules to make your store faster.
Just review them every so often and deactivate those rules that are obsolete, non-applicable, or otherwise useless. Reducing the number of conditions will mean that Magento has to check for less stuff before it can execute all the necessary shopping cart JS code.
Reason 2. You Never Remove Useless Shipping Carriers
The more shipping carriers you have, the longer it takes for Magento to communicate with them. Magento takes time to query the shipping carrier API server and fetch its response. Most of the time Magento will have to ask the carrier to fetch the estimated shipping price for the current cart. Every time the contents of the cart changes, you get another holdup before the estimated shipping cost refreshes.
Now imagine you have 6 carriers with an average roundabout time (ask and fetch response) of 100 ms. Each of them has to get the information about your products and their parameters, evaluate the prices, and return an estimated shipping cost. That is 600 ms of just working with the carriers!
Go to Stores > Configuration > Sales > Shipping Methods and disable carriers you never use.
Reason 3. Magento Constantly Checks for Available Stock
Do you know what exactly happens when you put something in your shopping cart? Magento has to fetch that item from somewhere, right? And when we have a crowd of customers putting stuff in their carts and then checking out, Magento needs to make sure that the items they put in the cart actually exist in stock.
Without this check, it’s entirely possible to put an already sold out product in a cart of a new buyer. Which will of course then result in failure when they want to go to checkout with it. To avoid this situation, Magento will constantly check item availability on every Add to Cart event.
The alternative to this mechanics is not for everyone. You have an option to actually turn this inventory check off. Sure, you’ll have to deal with a few angry customers here and there but overall the shopping experience will improve drastically. This is especially true if you have a lot of products in stock and don’t run out on things during the day.
Go to Configuration > Settings > Catalog > Inventory > Product Stock Options and disable stock. This is a last-resort measure, use with discretion.
Reason 4. You Never Use MAP in Advanced Sales
MAP is Minimum Advertised Price and it’s a useful tool when you sell products that require a MAP indication. Most of the stores, however, never use MAP. Which is a good reason to turn it off for good.
In Magento 2 Admin Panel, go to Stores > Configuration > Sales > Sales and select NO in Enable MAP.
Reason 5. You Never Do Any Homekeeping
Homekeeping is the umbrella term that can indicate a wide range of operations that don’t necessarily improve speed of the store but help maintain current performance gains and stop performance deterioration. They usually consist of cleanups, small fixes, and general maintenance. If you neglect homekeeping chores for long enough, they can become a good source of performance gain.
Truncate the database. Over time, Magento tends to become a little unkempt. As a diligent store owner, your task is to keep things tidy. A relatively easy way to do so is truncating Magento Database to speed up your shopping cart. Consult your developer team to find out which tables need trimming. Ensure you don’t damage the tables that are actually important and should not be truncated.
Remove unused extensions. One of the reasons your store was faster back when you just launched it was because it didn’t have to execute so many lines of third-party JS code. Revisit your third-party extensions that might slow down your shopping cart experience and disable those you can live without.
More often than not those extensions are poorly optimized and only work well in the pristine environment of the demo store where there are no other extensions or customizations that take up the precious server resources.
If you follow our instructions, you should once more have a snappy shopping cart experience. In case your efforts did not get you the result you expected, there’s one last thing you can do: profile the code manually. Find the bottlenecks in your Add to Cart performance with Magento Profiler, MGT Developer Toolbar, or Aoe Profiler. The idea here is to carefully assess the loading process of your shopping cart and discover bottlenecks.
Some tips for manual code profiling and optimization:
- Look out for code that takes too long to execute but isn’t mission-critical for initial load – move it to the end of the page, speeding up time-to-interactive.
- Reduce excessive CSS and other design elements to make your Shopping Cart lighter. Sacrifice good looks for speed. The goal of the cart is to close a sale, not to show off how beautiful your store is. Minify and gzip-compress CSS/HTML to make them lighter and more compact.
- Consider merging Checkout and Shopping Cart with a single-page checkout extension. A single page is more likely to get you a customer since it is simpler and cuts down on the necessary steps to close the deal.
Apply advanced JS bundling techniques to make JS faster. In case you go this road don’t use the built-in Magento JS bundling option. It’s poorly optimized and doesn’t bring much value to the table. Opt for Magento 2 DevTools as a Chrome extension to generate a quality build.js solution.