What Actually Loads Before LCP
Largest Contentful Paint on a Magento 2 storefront is almost always one of three elements: the hero image on the home page, the product image on a product page, or the H1 plus tagline above the fold. To paint that element fast the browser has to traverse a long critical path: DNS, TLS, server connection, server-side application response, HTML download, render-blocking CSS, then the LCP resource itself.
Every lever in this article maps to a specific bottleneck on that critical path. The ones that move LCP do so because they shorten one of those steps by a meaningful number of milliseconds. The ones that do not move LCP do not, no matter how often you read them online.
Below is the prioritized list in order of LCP impact, then a short list of changes that look productive but do not move the needle.
Lever 1: Production Mode And A Proper Cache Stack
Magento 2 running in default or developer mode is unusably slow in production. The first thing to check on a storefront that feels slow is the mode.
bin/magento deploy:mode:show
If it returns anything other than production, fix that first:
bin/magento deploy:mode:set production
bin/magento setup:di:compile
bin/magento setup:static-content:deploy
Beyond mode, the cache stack does the heavy lifting. The minimum responsible Magento 2 cache layout is:
- Redis or Valkey for the session and default cache.
- Varnish in front of the application for the Full Page Cache.
- A CDN in front of Varnish for static assets and ideally for cacheable HTML.
The single fastest win on a Magento 2 storefront is moving from the built-in file cache to Redis or Valkey for sessions and default cache. TTFB drops, every page benefits.
Varnish in front of the application is the second-largest single win. With FPC delivered from Varnish, anonymous traffic on cached pages bypasses PHP entirely. TTFB on those pages goes from 500-1500 ms (PHP-rendered) to under 100 ms (Varnish-served). LCP follows TTFB closely on Magento, so this directly compresses the LCP number.
Lever 2: A Fast PHP-FPM Pool For Uncacheable Traffic
Even with Varnish, every logged-in customer, every checkout step, every add-to-cart, and every cart preview hits PHP. PHP-FPM pool sizing and worker count is the second-most-impactful tuning step.
A reasonable starting configuration for a modern Magento 2 store on a single application server with 8 GB RAM:
pm = dynamic
pm.max_children = 30
pm.start_servers = 8
pm.min_spare_servers = 4
pm.max_spare_servers = 12
pm.max_requests = 500
Plus OPcache properly configured:
opcache.enable = 1
opcache.memory_consumption = 512
opcache.max_accelerated_files = 130000
opcache.validate_timestamps = 0
opcache.save_comments = 1
OPcache with validate_timestamps = 0 saves a stat() per included file per request. On Magento 2, with around 10,000 included files per request, this alone cuts measurable response time.
Lever 3: The LCP Image Itself
The single biggest LCP killer on most Magento 2 storefronts is the LCP image not being optimized, not being preloaded, or not being delivered in a modern format.
Three fixes in order:
Convert the LCP image to WebP or AVIF. A 200 KB hero JPEG becomes a 60-90 KB WebP. The browser downloads less data. Use Magento's built-in image processor or, for category and product images, a third-party module that produces WebP variants at upload time.
Preload the LCP image. Add a <link rel="preload"> for the hero or main product image in the document head. The browser starts the image request before parsing the rest of the HTML.
<link rel="preload" as="image"
href="/media/wysiwyg/hero.webp"
imagesrcset="/media/wysiwyg/hero-mobile.webp 768w,
/media/wysiwyg/hero.webp 1920w">
Set explicit width and height attributes on the LCP image, plus a responsive srcset. The browser allocates space immediately (preventing CLS) and downloads the right size for the viewport.
Together, these three changes on the LCP image alone typically take 800 to 1500 ms off LCP on a mobile connection.
Lever 4: Drop Or Defer Render-Blocking JavaScript And CSS
Default Magento 2 frontends ship a lot of CSS and JS that blocks rendering. The browser sits idle, waiting for stylesheets to download and parse, while the LCP image queue waits.
The cheap fix: add async or defer to third-party scripts (analytics, chat widgets, A/B testing). None of them need to block the first paint.
The bigger fix: switch to a frontend theme that does not ship 800 KB of jQuery, RequireJS, and KnockoutJS for every visitor. Hyva is the current industry default for this. Its frontend ships closer to 50 KB of JS, removes RequireJS entirely, and is the largest single LCP improvement available to a Magento 2 store today. The migration is not free but the return is.
If a Hyva migration is out of scope, the medium-effort path is critical CSS extraction: inline the CSS needed for the above-the-fold content directly in the document head, and defer the rest. The browser can paint LCP without waiting for the full stylesheet.
Lever 5: A CDN With HTML Caching, Not Just Static Caching
Most stores put their static assets on a CDN. Fewer put their HTML on the CDN. Magento 2 with Cloudflare or Fastly in front of Varnish, configured to cache HTML for anonymous users, takes the LCP image and its document delivery to the edge.
Customer-specific HTML (cart counter, customer name, recently-viewed) is handled with Edge-Side-Includes or with Magento's existing customer-data JavaScript hydration. Anonymous visitors get the cached HTML edge-fast. Logged-in visitors fall through to Varnish, which is still fast.
The LCP improvement from putting HTML on a CDN is roughly equivalent to the geographic distance from the visitor to the origin server. A US visitor to an EU-hosted store sees their LCP drop by 100 to 250 ms once the HTML moves to a CDN edge in their region.
Lever 6: Font Loading Done Properly
Custom web fonts are a common LCP regression cause. The H1 is the LCP element. The H1 needs a custom font. The custom font is fetched late, the browser blocks rendering of the H1 until the font arrives, and LCP balloons.
Three concrete fixes:
- Use
font-display: swapin @font-face declarations. The browser renders text in the fallback font immediately and swaps in the custom font when it arrives. - Preload the font file:
<link rel="preload" as="font" type="font/woff2"
href="/static/fonts/inter-regular.woff2" crossorigin>
- Self-host critical fonts. A request to fonts.googleapis.com adds a DNS lookup, a TLS handshake, and a redirect. The fonts are not magically faster from Google; self-hosting cuts the round trips.
Lever 7: A Mean Lean Above-The-Fold
Every CMS block, every static block, every product widget that renders above the fold adds work to the critical path. If the page above the fold is a hero image, a heading, and a CTA, the page loads fast. If it is a hero image plus a featured-products carousel plus a newsletter form plus a recently-viewed widget plus three trust badges fetched from a third-party service, the page loads slowly. There is no magic configuration that fixes a heavy above-the-fold.
The lever here is editorial, not technical: review what is above the fold on the home, category, and product page. Move everything below the fold that does not need to be at the top. Sometimes the LCP win from this single decision is larger than any other lever in this list.
What Does Not Move LCP
A short list of changes that get recommended on Magento speed-up checklists but do not meaningfully move LCP:
- Database indexes. Indexer cron, index rebuilds, partial indexing. These affect product catalog operations and admin response time. They do not change the LCP path for a cached anonymous page hit.
- Switching from MySQL to MariaDB. Microbenchmarks differ. Magento workloads do not see a real-world LCP shift.
- A bigger application server. If you are bottlenecked on TTFB and the cache stack is correct, the server is rarely the limit. A 16 vCPU machine serves cached pages no faster than an 8 vCPU machine. Save the budget for Varnish RAM or for the CDN.
- Removing all CSS and JS. Removing too much breaks the page in ways that customers notice. Critical CSS extraction is the smarter version of this idea.
- Lazy-loading the LCP image. This is the most common own-goal. The LCP image must NOT be lazy-loaded. It is the first thing the browser should fetch. Lazy-loading it adds 500 to 1000 ms to LCP. Audit your theme's image attributes.
The 1-Day Audit Sequence
A senior LCP audit on a Magento 2 store, end to end, in one day:
- Lighthouse and WebPageTest run from a cold cache on home, category, and product page. Record the LCP, the LCP element, and the critical path waterfall.
- Identify the LCP element on each page type. Check that it is not lazy-loaded, has explicit dimensions, is in a modern format, and is preloaded.
- Inspect the cache stack. Confirm Redis or Valkey for session and default cache. Confirm Varnish is serving anonymous traffic. Confirm the CDN is fronting both static assets and HTML.
- Inspect PHP-FPM and OPcache configuration. Verify the pool sizing and OPcache settings against the targets in Lever 2.
- Inspect the frontend. Theme stack (legacy vs Hyva), critical CSS handling, font loading, render-blocking third-party scripts.
- Inspect the above-the-fold. Count the elements, count the requests, count the third-party calls. Recommend the cuts.
- Apply the highest-impact change first (often LCP image plus Varnish), rerun Lighthouse, record the new LCP.
- Repeat with the next-highest-impact change. Stop when LCP is under 2.5 s on a mid-tier Android over 4G, or when the remaining levers all cost more than the LCP delta they would buy.
Done well, one day produces a 500 to 1500 ms LCP improvement on a typical neglected Magento 2 storefront, plus a written playbook the team can apply to future regressions.
Bottom Line
Magento 2 LCP is moved by a short list of high-leverage changes: production mode plus a real cache stack, a tuned PHP-FPM pool, an LCP image that is small, preloaded, and in a modern format, less render-blocking CSS and JS, a CDN doing HTML caching, fonts loaded with display: swap and preload, and a lean above-the-fold. Everything else is noise.
If you want this audit run end-to-end on your store with the levers pulled in order of impact and a documented before-and-after, that is the Magento 2 speed optimization engagement. One senior engineer, one day, one document, real LCP improvement.
Need help with this?
Our team handles this kind of work daily. Let us take care of your infrastructure.
Related Articles
How to Boost Magento 2 Performance in a Few Easy Steps
Magento 2 delivers incredible flexibility for eCommerce, but without proper optimization it can become sluggish. This guide walks through ten proven DevOps strategies to dramatically speed up your store, from PHP upgrades and full-page caching to Varnish, Redis, CDN configuration, and ongoing code audits.
MagentoHow to Upgrade Magento 2 from 2.4.7 to 2.4.8
Keeping Magento current is critical for security, performance, and compatibility. This step-by-step guide walks developers through upgrading from Magento 2.4.7 to 2.4.8, covering system requirements, pre-upgrade checks, Git workflow, Composer commands, and post-upgrade validation.
MagentoHow to Completely Disable "Compare Products" in Magento 2
Magento's built-in Compare Products feature can add unnecessary clutter and slow down page loads. This guide shows you how to fully remove it using layout XML overrides, CSS rules, and a quick CLI deploy -- keeping your storefront clean and fast.