Hacker News

Favorites Setup
Comment by bingemaker | original | HTML Can Do That
[−]bingemaker · 2026-08-20 Thu 15:39 UTC · link
<img> also supports "srcset" which can make the image component responsive. Hope they add a placeholder to it which can account for loading state.
[−]theandrewbailey · 2026-08-20 Thu 23:33 UTC · link
I find using <picture> with <source> and <img> is more flexible, particularly with multiple image formats (AVIF and JPG in my case).
[−]callc · 2026-08-21 Fri 02:45 UTC · link
One more thing thats nice with <picture> and <source> and <img> over <img> with srcset is the former can responsively change images, while some browsers (Chromium based IIRC) will assume srcset corresponds to the “same looking” image.

IIRC Chromium based srcset will never “downsize” to a smaller image, whereas <source>’s media is like a real media query.

Use if you want jumpscares at specific sizes lol

[−]account42 · 2026-08-21 Fri 12:20 UTC · link
I wish both srcset and <source> elements wouldn't be so redundantly verbose by forcing you to specify the full (relative) URL for each image when they usually only differ by a small part specifying the resolution or format. Sure, transfer-encoding will mostly nullify the overhead but it's still annoying when editing the HTML manually.
[−]theandrewbailey · 2026-08-21 Fri 15:05 UTC · link
Ah, don't edit the HTML manually. Name your images brain-dead predictably, and use a script with some regex.

My blog has some code that searches for <img> tags just after markdown conversion, then uses the src to find similarly named images (image×1.jpg, image×2.jpg, etc.) to use in <source> tags.

https://github.com/theandrewbailey/gram/blob/master/gram/src...

https://github.com/theandrewbailey/gram/blob/master/gram/src...