Commit c7d0453
committed
Image: default lazy images to sizes="auto" for optimal srcset selection
The JS Image component injects the real <img> only once it scrolls into view,
at which point its box is already laid out, so sizes="auto" resolves from the
rendered width. Add loading="lazy" + sizes="auto, 100vw" to the injected <img>
(and the shared <source> elements / noscript fallback) when no explicit sizes
is given and the image is not priority. Verified in Chrome: a 400px slot now
fetches the 400w candidate instead of the 1600w one. Degrades to 100vw on
browsers without sizes="auto" support (e.g. Safari) — no regression.1 parent 5b34ece commit c7d0453
1 file changed
Lines changed: 20 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
202 | 202 | | |
203 | 203 | | |
204 | 204 | | |
205 | | - | |
206 | | - | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
207 | 223 | | |
208 | 224 | | |
209 | 225 | | |
| |||
298 | 314 | | |
299 | 315 | | |
300 | 316 | | |
| 317 | + | |
| 318 | + | |
301 | 319 | | |
302 | 320 | | |
303 | 321 | | |
| |||
0 commit comments