<img sizes="auto, 100px" loading="eager">
: auto
equates to 100wv
but should ideally be ignored
#10110
Labels
<img sizes="auto, 100px" loading="eager">
: auto
equates to 100wv
but should ideally be ignored
#10110
What is the issue with the HTML Standard?
This is a request to change how
<img sizes="auto">
works for non-lazy images. I hope it’s not too late for this to happen!TL;DR: instead of defaulting
auto
to100vw
, default it to the current layout width of the image, when available. This will help single-page apps – which can simply addsizes="auto"
on all images:and have the browser automatically pick the best image when a single-page navigation happens, as the layout is already built.
Motivation
When the spec was still drafted, I misread it and was very excited something like this would be supported once the spec ships:
This behavior – when
auto
defaults to layout size (when available) – is helpful for SPA authors. It allows to addsizes="auto"
to all (not just lazy-loaded) images – and get a perfectly sized image loaded automatically whenever a single-page navigation happens.As it turned out, the spec doesn’t work that way. When you put
sizes="auto"
on a non-lazy image,auto
defaults to100vw
– even if the layout size for the image is already available:This significantly increases friction to optimizing single-page navigations. If you want to make use of the layout sizes that are already available on an SPA nav, you need to:
<img>
tag is rendered on the server or on the client,<img>
tag is rendered as a part of the first load or a subsequent navigation,sizes="auto" loading="lazy"
attribute to the<img>
tagAs it stands, many SPA authors won’t even think or attempt to ship an improvement like this.
Requested change
Instead of defaulting
auto
to100vw
:auto
and fall back to the next value in thesizes
attribute, otherwise.The text was updated successfully, but these errors were encountered: