Menu

A reader told me to ship sizes with my srcset. I had no srcset, and desktop wastes more than mobile
📰

A reader told me to ship sizes with my srcset. I had no srcset, and desktop wastes more than mobile

DEV Community: html·Zhou Jia·10 days ago
#jTEjCddZ
#devto2#devto#dev#card#desktop
Long article (783 words) — no AI summary yet.
Reading 0:00
15s threshold

A comment on my last image post said:

Ship sizes with it. With width descriptors and no sizes , the browser assumes the image is 100vw.

Good advice. I went to check my markup before writing the fix. There was no srcset to add sizes to.

What the page actually has

products.html , 122 <img> tags:

attribute count

srcset 0

sizes 0

loading="lazy" 120

fetchpriority="high" 1

So the post I wrote about lazy loading was accurate and also beside the point. Lazy loading changes when an image is fetched. It does nothing about how big the file is. Every card on that page ships one fixed file, whatever the viewport.

Measuring rendered vs natural

Reading the HTML only tells you the width / height attributes, which are the intrinsic dimensions, not the layout size.…

Continue reading — create a free account

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