Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

You’d think, right? But I tried that approach, and I don’t remember what the issues were but there were problems. Unless I was doing something wrong. Either way, yes, you need the dimensions ahead of time, which is reasonable and not my gripe.


> Unless I was doing something wrong

Probably this, that approach is very standardized now across the major browsers.

I worked at a web agency until last year, and led projects to inline image height/width values for 4 large companies. Huge reduction in CLS and permits you to lazyload without fear of layout shifts.

`aspect-ratio` hadn't landed in iOS Safari at that point, but you can do that instead now. Identical behavior.


Well, if you set max-width: something for example. You need to set other dimension as auto in CSS. So that would be height: auto.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: