Hacker News new | ask | show | jobs
by afavour 1881 days ago
> The answer is why the hell am I being forced to figure this out?

Because the decision is made before CSS loads and is parsed, so the browser doesn’t know any of this.

Don’t get me wrong, this frustrates me endlessly as well, but the reasons for it are clear. Delaying until CSS has been parsed would slow down image loading.

1 comments

If we can lazy-load the image until the image is in view, we can lazy-load until its container width has been determined. I get there’s reasoning for how things behave as they do, my point is really we’re in this position due to lack of foresight by WHATWG/W3C.
For images where you don’t declare the ratio it can’t completely determine the width until the image is loaded.
If you don't declare the width/height or intrinsicsize, then you've just opted out of loading an image by its container size, pretty simple.