Menu

Which image does Next.js Image fetch? Compare src, srcset, and currentSrc in a browser
📰

Which image does Next.js Image fetch? Compare src, srcset, and currentSrc in a browser

DEV Community: nextjs·hiro@·6 days ago
#10QdDXGM
#devtonextjs#devto#dev#sizes#loading
Reading 0:00
15s threshold

The src emitted by Image did not, by itself, reveal the width actually downloaded. In this test, an image whose src pointed to width 3840 had a browser currentSrc pointing to width 640.

Inspect generated img attributes, the URL chosen by the browser, and that URL's response separately. This comparison uses the same synthetic image for ordinary img and Next.js Image.

Give the images the same CSS display width

The source is a 1600×1000 PNG. Identical pixels were saved under different filenames to avoid sharing the same URL cache between images. It is a regular color pattern for testing, not an input representative of photographic compression.

The page was:

import Image from 'next/image' ; const responsiveStyle = { display : 'block' , width : '50vw' , height : 'auto' } ; export default function Page ( ) { return < main > < img id = "plain" src = "/plain.png" alt = "Plain test pattern" width = { 320 } height = { 200 } style = { responsiveStyle } /> < Image id = "fixed" src = "/fixed.png" alt = "Fixed…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.