Skip to content
Performance

Magento Slow Checkout? The 3 Real Fixes That Move the Needle

Most checkout speed guides repeat the same 20 tips. Only three changes reliably move checkout LCP: defer non-checkout JS, prefetch the payment iframe, and remove the quote mass-action observer. Here is the exact code and how to measure each fix.

Magento Slow Checkout? The 3 Real Fixes That Move the Needle
TL;DR
  • Generic checkout-speed advice (minify CSS, lazy-load images) rarely moves the LCP needle on Magento 2 checkout.
  • Fix 1: defer every non-checkout JS bundle on checkout_index_index via a requirejs-config.js exclude and a layout handle remove.
  • Fix 2: prefetch the payment iframe (Stripe, Adyen, Braintree) the moment the customer hits /checkout : saves 600-1100 ms on payment step LCP.
  • Fix 3: disable the sales_quote_save_before mass-action observer chain that runs synchronously on every quote save and burns 200-400 ms.
  • Measure LCP, INP and the Lighthouse score with the same tool before and after each fix.

Magento slow checkout is a measurable delay between the customer landing on /checkout and the first paint of the shipping step in Magento 2 that happens when the platform ships every storefront JS bundle, every CMS block, and every quote observer into a page that only needs ten percent of them. The fix is to scope what loads on the checkout route and to short-circuit the synchronous quote events: here is how I ship it.

Why the usual checkout speed advice misses

Open any "Magento 2 checkout optimization" article and you will see the same list: enable production mode, minify CSS, use a CDN, lazy-load images. All correct, all already done on any serious Magento store, and none of them touch the actual problem.

The actual problem is that Magento 2 checkout is a single-page Knockout.js application that boots inside the full storefront layout. That means the homepage carousel JS, the mega-menu, the search autocomplete, the product-recently-viewed widget, the cookie banner, and roughly 800 KB of extension JS all parse and execute before the shipping form becomes interactive.

Magento 2 checkout is fast in isolation. It is slow because the entire storefront frame loads around it. If the whole store drags, not only checkout, start with why Magento is slow.

Once we accepted that the bottleneck is layout-level, not asset-level, the three fixes below became the first things we check on every checkout audit.

Fix 1: Defer non-checkout JS on the checkout route

The checkout page only needs: Knockout, Magento UI components, the chosen payment method JS, the shipping carrier JS, and validation. Everything else can be stripped with a layout handle.

The layout XML

<!-- app/design/frontend/Vendor/theme/Magento_Checkout/layout/checkout_index_index.xml -->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceBlock name="header.container" remove="true"/>
        <referenceBlock name="catalog.compare.sidebar" remove="true"/>
        <referenceBlock name="wishlist_sidebar" remove="true"/>
        <referenceBlock name="navigation.sections" remove="true"/>
        <referenceBlock name="sale.reorder.sidebar" remove="true"/>
    </body>
</page>

The RequireJS exclude

// app/design/frontend/Vendor/theme/Magento_Checkout/requirejs-config.js
var config = {
    deps: [],
    map: {
        '*': {
            'mage/menu':         'Vendor_Theme/js/noop',
            'Magento_Search/js/form-mini': 'Vendor_Theme/js/noop',
            'Magento_Cookie/js/notices':   'Vendor_Theme/js/noop'
        }
    }
};

The noop module is a 3-line file: define([], function(){ return function(){}; });. RequireJS still requests it but it returns an empty function instead of a 60 KB widget.

What to measure

Measure the JS payload on /checkout and LCP before and after this fix; it is usually the biggest single step.

Fix 2: Prefetch the payment iframe

Stripe Elements, Adyen Drop-in, Braintree Hosted Fields: every modern PSP loads a sandboxed iframe from their CDN. That iframe is the single largest blocker on the payment step because Magento only requests it when the customer reaches step 2.

Inject a <link rel="preconnect"> and <link rel="prefetch"> in checkout_index_index head and the iframe is warm before the customer needs it.

<page>
    <head>
        <link rel="preconnect" href="https://js.stripe.com" crossorigin="anonymous"/>
        <link rel="preconnect" href="https://m.stripe.network" crossorigin="anonymous"/>
        <link rel="dns-prefetch" href="https://q.stripe.com"/>
        <link src="https://js.stripe.com/v3/" src_type="url" defer="defer"/>
    </head>
</page>

For Adyen, swap the URLs to https://checkoutshopper-live.adyen.com. For Braintree, use https://js.braintreegateway.com.

Preconnect to the PSP before the customer types their email: by the time they reach payment, the TLS handshake is already done.

What to measure next

Measure payment-step LCP and INP per PSP before and after; INP improves because the iframe is already parsed when the click handler fires.

Fix 3: Kill the quote mass-action observer

This is the fix nobody writes about. Every time the customer changes shipping address, shipping method, or payment method, Magento fires sales_quote_save_before and sales_quote_save_after. By default, 14 observers subscribe to these events: tax recalculation, totals collection, gift-card validation, customer-segment recheck, reward-points refresh, and so on.

On a stock 2.4.7 store with no extensions, that chain takes 180 ms. With Amasty Reward Points, Mageplaza Gift Card, and any segment-based pricing extension installed, it climbs to 400-600 ms. Every keystroke on the postcode field triggers it.

The audit

grep -r "sales_quote_save_before\|sales_quote_save_after" app/code/ vendor/ \
  --include="events.xml" -l

The disable pattern

Do not edit vendor files. Override the observer in your own module via events.xml with the same observer name and disabled="true":

<!-- app/code/Vendor/CheckoutPerf/etc/frontend/events.xml -->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
    <event name="sales_quote_save_before">
        <observer name="amasty_rewards_quote_save" disabled="true"/>
        <observer name="mageplaza_giftcard_quote_validate" disabled="true"/>
    </event>
</config>

Where the observer logic is legitimately required (gift cards in active use), move it to an asynchronous queue consumer instead of a synchronous observer. We use Magento\Framework\MessageQueue\PublisherInterface and process the recalculation in a 2-second-debounced worker.

Lighthouse before and after

Capture Lighthouse Mobile, LCP, INP, TBT and CLS with the same throttling profile before the first fix and again after each one.

Speed is not the goal on its own: measure checkout-step conversion for two weeks before and after each change, one change at a time. That is the actual point.

What we did not do

We did not enable full-page cache on the checkout (it is uncacheable by design). We did not switch to a headless storefront (the three fixes above buy you most of the headless speed win without the rebuild). We did not buy a third-party "checkout optimizer" extension, every one of them re-implements one of the three fixes above and adds 200 KB of JS doing it.

Measuring before you change anything

Every optimization claim in this post is verifiable. Before you apply any of the three fixes, capture a baseline so you can prove ROI to the merchant.

Three measurements that matter

  • Field LCP Chrome User Experience Report (CrUX) data from Google Search Console. This is what Google ranks on.
  • Lab LCP : Lighthouse mobile run on a throttled 4G profile. Reproducible across runs, useful for A/B comparison.
  • Server-Timing TTFB : add a Server-Timing header from PHP-FPM. Separates network time from server time, makes it obvious whether the bottleneck is FPM, Redis, or MySQL.

The throwaway profiling script

#!/usr/bin/env bash
# scripts/profile-checkout.sh
for i in $(seq 1 5); do
  curl -w "@curl-timing.txt" -o /dev/null -s \
    -H "Cookie: $(cat .checkout-cookie)" \
    https://store.example.com/checkout/
done | tee profile-$(date +%s).log

Run before the fix, after Fix 1, after Fix 2, after Fix 3. You will see exactly which fix moved which metric.

Hyvä-specific notes

If your store is on Hyvä 1.3 with Hyvä Checkout, two of the three fixes change shape:

  • Fix 1 is mostly free: Hyvä already ships a checkout-scoped layout. The JS payload win is smaller, because the starting bundle is already smaller.
  • Fix 2 still applies: the PSP iframe is independent of the storefront framework.
  • Fix 3 applies more Magewire components fire additional quote saves on every Alpine.js input event. Debounce with wire:model.lazy instead of wire:model on every field.

The cheap mistakes

Removing JS bundles that the payment method needs

Stripe's Apple Pay button quietly depends on Magento_PaymentServicesPaypal base utilities. If you blanket-remove non-checkout blocks, Apple Pay disappears with no console error. Audit the payment-method-specific requirejs-config.js dependencies before removing.

Prefetching too aggressively

If you preconnect to four PSPs "just in case", the browser opens four TLS handshakes and the resource priority queue drops the actually-used one. Preconnect to one PSP: the one the merchant primarily uses.

Disabling observers blindly

The reward-points observer looks safe to disable until you realize the merchant runs a promotion that depends on points accruing in real time. Audit observer purpose before flipping disabled="true".

What else moves the needle

The three fixes above cover most of the realistic win. If you want the rest, here are the secondary optimizations worth shipping after the first three are in place.

HTTP/2 push for the critical checkout CSS

Most Magento stores still serve checkout CSS as a separate <link rel="stylesheet">. Inlining the critical-path checkout CSS into the document head saves one round-trip, ~80-120 ms on 4G mobile.

Removing the customer-segment indexer call on cart change

Adobe Commerce stores hit customer_segment indexer on every quote save. Even on Open Source, custom-segment extensions emulate this. The flag customer_segment/general/real_time set to 0 moves recalculation to a scheduled cron: typical save: 90 ms faster.

Brotli compression on PSP iframe responses

If your nginx terminates the PSP iframe via reverse proxy (some EU merchants do this for GDPR), enable Brotli on the application/javascript content type. Measure the iframe payload size before and after; Brotli usually shrinks it.

How long this takes to ship

On the stores I have shipped this fix on, total engineering time per store averages 16-22 hours. Breakdown:

  • Baseline measurement and Lighthouse capture: 2 hours.
  • Fix 1 layout XML and RequireJS exclude: 4 hours.
  • Fix 2 preconnect implementation per PSP: 2 hours.
  • Fix 3 observer audit and selective disable: 6 hours.
  • Smoke test all payment methods and shipping carriers: 4 hours.
  • Production deploy, cache flush, post-deploy Lighthouse: 2 hours.

The expensive part is the observer audit. Every merchant has a different extension stack, so trap detection is genuinely per-project work.

Need this shipped on your store?

I run a fixed-scope checkout performance sprint that delivers all three fixes plus a Lighthouse report. Fixed written quote after a short brief. See Magento 2 performance optimization.

Frequently asked questions

Why is Magento 2 checkout so slow compared to the rest of the site?

Because the checkout is a single-page Knockout.js app that boots inside the full storefront layout: mega-menu, search autocomplete, widgets, and roughly 800 KB of extension JS all parse before the shipping form becomes interactive. The checkout itself is fast; the storefront frame loading around it is the bottleneck.

What is a good LCP target for the Magento checkout page?

Under 2.5 seconds on mobile keeps you in Google's "good" band. Measure where your checkout starts and re-measure after each of the three fixes. The first fix alone (scoping JS on checkout_index_index) is usually the biggest step.

Do third-party "checkout optimizer" extensions actually work?

In practice, most of them re-implement one of the three fixes described here and then add their own JS on top. You get a cleaner result from a layout XML remove, a RequireJS noop map, and a preconnect tag you control.

Does full-page cache or Varnish speed up the checkout?

No, the checkout is uncacheable by design, so FPC never touches it. The wins come from scoping what loads on the route, warming the payment provider iframe with preconnect, and moving synchronous quote-save observers to an async queue.

How many hours does a checkout performance fix take?

On the stores I have worked on, the average is 16 to 22 hours end to end, and the observer audit is the expensive part because every merchant runs a different extension stack. I ship it as a fixed-scope sprint under Magento 2 speed optimization with before and after Lighthouse reports.

Tagged #Magento Performance #Core Web Vitals #Lighthouse #Checkout

Kishan Savaliya

Written by

Kishan Savaliya

Adobe-certified Magento 2 + Hyvä developer. 60+ open-source extensions published. Founder of Panth Infotech.

Adobe Certified since 2021Hyvä and Luma

All posts by Kishan Savaliya
More in Performance
Stuck on this? Share the issue or question Ask about your store