Every article on this subject opens with Amazon losing 1% of sales for each 100ms of delay. I don't have Amazon's traffic, and I'm in no position to check that number.
What I do have is three things I built this year that sell something. One is a Shopify theme for a clothing brand. One is a static marketing site for a flooring contractor. The third is the embeddable estimator from my own app, EstimateFlow, which runs inside other people's websites. I went through all three and counted bytes. This post is what I found, and that includes a few things I got wrong.
I have no Lighthouse scores or field data recorded for any of these sites, so everything below is file sizes, markup and reasoning.
The hero image is the LCP element
On a store's home page, the largest thing the visitor sees first is nearly always the hero photograph. That makes it the Largest Contentful Paint element, and LCP is the Core Web Vital that a storefront finds hardest to keep low.
The Shopify theme's hero is a slideshow. The first slide is the only one that matters for loading, so it's the only one loaded eagerly:
assign loading = 'lazy' assign priority = 'auto' if forloop.first assign loading = 'eager' assign priority = 'high' endif
Every other slide is lazy. The browser fetches slide one at high priority and leaves the rest until they're needed.
Next comes size. A merchant's uploaded image goes through Shopify's CDN, which will resize on request, so the tag offers five widths and lets the browser choose:
{{ b.image | image_url: width: 2400 | image_tag: loading: loading, fetchpriority: priority, sizes: '100vw', widths: '600,900,1200,1800,2400', alt: '' }}
A phone gets the 600 or 900 pixel version. Nothing downloads the 2,400 pixel file unless the screen can use it.
Phones need a different photo
A wide hero looks bad on a phone however well it's compressed. If you crop a landscape photo to a tall screen, you're left with a narrow strip from the middle, heavily zoomed. So each slide can have a second, portrait image, and a <picture> element switches between them:
{%- comment -%}
Phones get a portrait photo when one is set: cropping a wide
photo to a tall screen leaves only a narrow, over-zoomed strip.
{%- endcomment -%}
<picture>
{%- if b.mobile_image != blank -%}
<source
media="(max-width: 749px)"
srcset="{{ b.mobile_image | image_url: width: 600 }} 600w, {{ b.mobile_image | image_url: width: 900 }} 900w, {{ b.mobile_image | image_url: width: 1200 }} 1200w"
sizes="100vw"
>
{%- endif -%}
I did this for the design. It turned out to be a performance win as well. The portrait crops in the theme are 1,080 pixels wide and weigh 86 to 131 KB each. The landscape originals are 2,400 wide, and one of them is 429 KB.
The mistake I found while writing this
The theme ships with demo photographs, so the layout can be judged before the brand's real pictures are uploaded. Those take a different code path:
<img
src="{{ b.demo_image | asset_url }}"
alt=""
width="2400"
height="1200"
loading="{{ loading }}"
fetchpriority="{{ priority }}"
>
There are two problems with it. Theme assets don't go through the image resizer, so there's no srcset, and a phone gets the full 2,400 pixel file. And the width and height are hardcoded to 2400 by 1200, while the three bundled heroes are really 2400×1099, 2400×1600 and 2400×1600. The browser uses those attributes to reserve space before the image arrives. If they're wrong, it reserves the wrong amount.
In this theme the hero has its height set in CSS and the image is positioned inside it, so nothing visibly jumps. On the live store every slide has a merchant image set, so the demo path doesn't run at all. But it will sit in the fallback code until the day somebody clears an image field.
In total the bundled photography is 19 JPEGs and 2.8 MB. That's acceptable for placeholders and would be far too much if they shipped to customers.
A carousel with no timer
Auto-advancing carousels usually run on setInterval. Mine has no timer in JavaScript. Each slide has a progress bar, and the bar's CSS animation is the clock:
// The active bar's fill animation is the timer: when it finishes, advance. // Pausing is then just pausing that animation, so progress is kept exactly.
When the animation ends, the script moves to the next slide. The pause button pauses the animation, and the bar stops exactly where it was. I didn't have to track any elapsed time.
It also stops working when nobody can see it:
// Hold the timer while the hero is scrolled out of view.
new IntersectionObserver(([entry]) => {
root.toggleAttribute('data-offscreen', !entry.isIntersecting);
}, { threshold: 0.2 }).observe(root);
Once the visitor has scrolled down to the products, the hero isn't swapping images and repainting above them. The touch and scroll listeners are registered as passive, so they can't hold up scrolling.
What a static export takes away
The contractor's site is Next.js, exported to static files and hosted on GitHub Pages. There's no server, which makes it cheap, and hard to take down.
A static export has no image optimiser, though. Next.js makes you say so in the config:
images: isGitHubPages ? { unoptimized: true } : undefined,
output: isGitHubPages ? "export" : undefined,
In the source I wrote this, sizes included:
<Image
src={assetPath("/images/interior-flooring.jpg")}
alt="Bright modern living space with natural wood flooring"
fill
preload
sizes="(max-width: 1023px) 100vw, 52vw"
/>
And this is what the export produced:
<img alt="Bright modern living space with natural wood flooring" decoding="async"
src="/images/interior-flooring.jpg"/>
The sizes attribute has disappeared, because without an optimiser there's nothing to choose between. Every visitor gets the same 1,600 pixel, 274 KB JPEG, whether they're on a phone or a desktop. The preload did survive, so at least it's fetched early.
My rule in that project's README is to keep hero images between 1,600 and 2,000 pixels wide and compress them before committing. That limits the damage and doesn't solve the problem. The proper fix is to generate two or three widths at build time and write the srcset by hand, and I haven't done it.
The JavaScript nobody asked for
That site has exactly three client components: the header with its mobile menu, and two pieces of the quote dialog. Everything else is static markup.
The exported home page still references nine JavaScript chunks. In the build I measured they came to 603 KB raw and 187 KB gzipped. That's React and the framework runtime, shipped so that a page of text and photos can hydrate a menu button.
For comparison, the fonts are 12 files and 297 KB, and the four photographs in the project come to about 1.1 MB. The JavaScript isn't the heaviest thing on the page, but it's the least justified.
Analytics is loaded so that it can't delay any of this:
<Script
src={`https://www.googletagmanager.com/gtag/js?id=${GOOGLE_TAG_ID}`}
strategy="afterInteractive"
/>
afterInteractive waits until the page has hydrated. The tag only runs once the page can be used.
A script that lives on someone else's site
The estimator is the piece I've been most careful with, because it runs on websites I don't control. If my script slows down a contractor's home page, they'll remove it, and they'd be right to.
The install snippet is one line, and the important word in it is async:
<script src="https://.../widgets/KEY" data-mode="modal" async></script>
The loader is plain ES5 with no dependencies. It's about 18 KB, or 5.9 KB gzipped. It creates an iframe that renders the estimator, and in the popup and bubble modes that iframe sits inside a hidden panel with loading"lazy"= on it, so the browser doesn't fetch the application until someone opens it.
There's one script for all three install modes. The mode is read from the tag's own data-mode attribute:
// Captured synchronously: document.currentScript is null by the time an async // callback runs, and the data- attributes live on this tag. var script = document.currentScript;
A contractor who switches from a popup to an inline form changes one attribute. And I serve one script per estimator where I'd otherwise serve three nearly identical ones.
The popup opens from any element on the host page marked with data-estimateflow-open. The loader doesn't look for those elements when it starts. It listens for clicks on the document:
// The popup is opened by the host page's own markup. Delegating from the // document means a button rendered later — a nav that hydrates, a CMS block — // works without the contractor re-running anything.
That matters on modern sites, where the button often doesn't exist yet when my script runs.
This one has a mistake in it too. The loader's response has no Cache-Control header, and the server looks the estimator up in the database on every request. I spent real effort keeping the install tracking off that request, and then left a query on it and no caching in front. It's a small query on an indexed column. It still runs once for every page view on every site that embeds the estimator.
I replaced a video with 600 KB of JavaScript, on purpose
EstimateFlow's home page has a "how it works" section. It has been three different things.
First it was a scripted tour made of HTML and CSS, which was a lot of markup to keep in step with the real product. Then it was a screen recording, a 3.9 MB MP4 with a 53 KB poster image. The video played muted, used preload"metadata"=, and only played while it was on screen. It was reasonably polite. It also looked like what it was, a framed clip with a play button and type that didn't match the page.
Now it's a three.js scene: a laptop that plays the three steps as you scroll. The chunk is 603 KB raw and 153 KB gzipped, and it's the largest file in the build.
On paper that's worse than a video the browser can stream. What makes it acceptable is when the cost is paid:
// Fetch and build the scene once the page is idle after loading, or sooner
// if the section comes within a screen of view first. Building it is the
// expensive part; done mid-scroll, it shows as a hitch.
observer = new IntersectionObserver(([entry]) => entry.isIntersecting && build(), { rootMargin: "100% 0px" });
observer.observe(trackRef.current);
const idle = window.requestIdleCallback
? window.requestIdleCallback(build, { timeout: 4000 })
: window.setTimeout(build, 1500);
Nothing else on the page imports three.js. It's fetched when the browser is idle, or when the section comes within one screen of the viewport, whichever happens first.
Downloading turned out to be the smaller problem. The first time a WebGL scene draws, it compiles shaders and uploads textures, and that showed up as a hitch at the exact moment the visitor scrolled the section into view. So the scene does that work early, while the canvas is still invisible:
// Compile every shader and upload every texture now, with the canvas still
// faded out. Left to the first frame, that work stalls the very scroll that
// brings the section into view.
await (renderer.compileAsync?.(scene, camera) ?? renderer.compile(scene, camera));
// Then draw each stage of the story once, so every canvas texture has been
// painted and uploaded in each of its states, and the shadow pass is built.
// One stage per task, so the page stays responsive while it loads.
for (const p of [0, 0.15, 0.3, 0.45, 0.6, 0.8, 1]) {
update(p, 0);
renderer.render(scene, camera);
await new Promise((resolve) => setTimeout(resolve));
}
The setTimeout between stages is what keeps the page responsive. Each render is a separate task, and the browser can handle input in between.
Three smaller decisions are in there as well. The scene is built from primitives and textures drawn on a canvas, so there's no model file to download. It only renders while it's on screen. And the pixel ratio is capped so that a very large display gives up some sharpness before it drops frames.
Without WebGL, the section falls back to a plain list of the three steps. Under reduced motion it shows each step's finished picture and doesn't animate.
What I haven't measured
All of the above is about bytes and timing I can reason about from the code. None of it is a measurement of what visitors experience.
I haven't recorded a Lighthouse run for any of these three projects. I have no field data, no LCP distribution and no performance budget in CI.
So I can't finish this post with a conversion figure. Counting was still worth doing. It found a fallback path that sends the wrong image dimensions, a static site that ships one image size to every device, 187 KB of JavaScript behind a menu button, and an uncached endpoint on my busiest route. Most of those I only noticed because I went through the output file by file.
If you run a store, I'd begin where I did. Open the network tab on your home page, on a phone, and sort by size. Find out which image is your LCP and how it's being loaded. After that, set up real measurement, which is the step I've been skipping.
