Checking the Images Next.js Actually Sends

A three‑column card layout can look right whilst downloading images sized for the whole window. Nothing overflows. Nothing appears broken. The browser has simply been given a rather generous estimate of how much space each photograph occupies.
This is worth checking when using next/image with fill. The parent controls the visible dimensions, but the browser also needs a useful sizes declaration when choosing from the generated image candidates. CSS and that declaration can disagree quite happily.
My introduction to next/image covers the component itself. Here I want to follow one image from its CSS box to the request the browser actually makes. I've put three versions of the same small Next 14.1 application in my download so that we can compare them without changing the picture, quality setting, or layout halfway through.
Measure the Box Before Writing the Hint
The example has 24 pixels of space on either side of the page and a content width capped at 1,120 pixels. Cards have a 24‑pixel gap. There is one column below 640 pixels, two from 640 pixels, and three from 1,024 pixels.
At a 1,280‑pixel viewport, the content has already reached its maximum width. Subtracting two gaps leaves 1,072 pixels for three cards: roughly 357.33 pixels each.
That is the width I want the browser to use when choosing an image. One third of the viewport would still overstate it, because the viewport includes space outside the capped content area.
The image fills a positioned parent with a four‑to‑three aspect ratio. That parent reserves the layout space. The sizes attribute doesn't set its CSS width, and writing sizes="64px" won't turn it into a tiny card. It will give the browser a poor basis for choosing the file to put inside the existing card.
I keep that undersized version as a deliberate comparison. It is very economical with bytes. Unfortunately, it is also economical with the image.
Describe Each Layout Range
For these particular gutters, gaps, and breakpoints, my matched declaration is:
<Image
src="/test-pattern.png"
alt="Coloured diagonal bands and a fine square grid"
fill
priority
quality={75}
sizes={[
'(min-width: 1168px) 357.33px',
'(min-width: 1024px) calc((100vw - 96px) / 3)',
'(min-width: 640px) calc((100vw - 72px) / 2)',
'calc(100vw - 48px)',
].join(', ')}
/>The first condition starts at 1,168 pixels: the 1,120‑pixel maximum content width plus the two outer gutters. Below that cap, the three‑column calculation subtracts 48 pixels of gutters and 48 pixels of gaps. The two‑column calculation subtracts the gutters and one gap. The final expression covers the single column.
These numbers belong to this layout. Copying them into a page with a sidebar or different gutters would preserve the syntax whilst losing the useful information.
The comparisons omit sizes, or supply the deliberately inaccurate 64px. The Next Image documentation explains the full‑viewport assumption used without a sizes declaration for a fill image. It also explains how sizes affects the generated width candidates. Looking only at whether the prop exists misses both the content of the hint and the resulting srcset.
All three variants use the same synthetic source image and quality setting. My test pattern is four‑to‑three too, so it matches the frame without needing a crop. The test pattern contains fine detail, so an undersized candidate has something meaningful to lose. I use priority consistently to request the visible test image promptly; loading priority is not what this comparison measures.
Read the Selected URL
The image's src attribute doesn't necessarily identify the candidate the browser selected. I inspect currentSrc after the image has loaded:
const image = document.querySelector('.frame img');
const { width: slotWidth, height: slotHeight } = image.getBoundingClientRect();
const selected = new URL(image.currentSrc);
console.log({
slotWidth,
slotHeight,
devicePixelRatio,
requestedWidth: selected.searchParams.get('w'),
sizes: image.sizes,
currentSrc: image.currentSrc,
});With Next's built‑in optimiser, that selected URL includes a width parameter. The fixture records the corresponding network response and decodes the returned image to check its actual width and height. This avoids treating a plausible query string as proof of what arrived.
I record naturalWidth too, but don't use it as a substitute for decoding the response. Browser‑reported intrinsic dimensions can account for the candidate's density. The pixel dimensions of the returned file answer a different question.
There's one more measurement to keep honest. With object-fit: cover, the picture can be larger than its frame before the browser crops it. A wide, shallow picture may have enough pixels across but still need scaling up to fill the height. I check both dimensions, or a tidy byte saving could simply be a smaller image scaled up further.
My responsive images article explains the browser's part in this choice. Next produces candidates; the browser selects among them. A measured slot of 357.33 CSS pixels does not require a file exactly 357 pixels wide. Available candidates and device pixel ratio both matter.
Give High‑Density Screens Their Own Check
The companion runs the comparison at 390, 800, 1,280, and 1,600‑pixel viewports, with additional double‑density checks at 390 and 1,280. Each variant starts in a fresh browser context.
With the picture and frame sharing an aspect ratio, a 357.33‑pixel‑wide card needs roughly 715 source pixels across at double density, and twice its CSS height in source pixels too. A candidate which is adequate in the ordinary‑density check may be insufficient here. Looking at one desktop screenshot wouldn't tell us that.
The checks compare both decoded dimensions against the measured box and device pixel ratio, allowing for the enlargement needed to cover the frame. They also confirm that the variants have identical visible dimensions, request the same source, and don't cause horizontal overflow. The tiny declaration must produce an undersized candidate; otherwise it hasn't demonstrated the failure it was intended to show.
A browser may reuse a larger cached image after a resize, and candidate choice can vary. Fresh contexts keep that reuse out of this experiment. They don't establish a universal rule that every browser will make precisely the same request on every visit.
Count the Bytes Without Inventing a Speed Test
For each selected response, my example records its encoded body size. In this controlled comparison, the missing declaration requests substantially wider images for the bounded desktop card, with larger responses than the matched declaration.
That is evidence of unnecessary image transfer for this layout and source. It isn't a measurement of Largest Contentful Paint, a CDN comparison, or a promise of the same saving for every photograph. The byte count excludes headers and protocol overhead, and the generated test image is deliberately detailed.
The smallest response is also not automatically the best result. The undersized control demonstrates why I check source pixels alongside bytes: making an image too small is an easy way to win an entirely unhelpful competition.
I would repeat the check after changing the container width, card count, or gaps. Those are CSS changes, but they can leave a previously accurate sizes declaration behind. A useful final check is pleasantly concrete: measure the space, inspect the selected request, and confirm that the file returned suits the space it has to fill.
Postscript
November 2026: I've retained Next 14.1 in this example and rerun it with the modern browser harness documented in the download. Its recorded response sizes and candidate choices come from that check, not an archived 2024 browser session. In Next 16, priority is deprecated in favour of preload; that changes how an early request is expressed, but doesn't make an inaccurate sizes declaration fit the layout.