Does anyone have any better suggestions for me than "go back to JPEG for my background images", to get reasonable-quality images on a webpage that still load comfortably on slow connections?
Note that anything that requires JS to function is not an option; I will not be implementing the pattern of "lazy-loading images after the fact", unless it can be made to work reasonably well without JS.
@joepie91 are you familiar with <picture> and <source>? they allow you to declare varying image qualities/formats, with user agents locally picking the best option
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/picture
💭 { my personal website makes heavy use of https://github.com/rbuchberger/jekyll_picture_tag to render images in jpeg/webp/jxl and output <picture> blocks }
@unlobito It's been brought up, but I'm unsure how this would be applied as a background image - aside from that, does this actually work to do progressive loading?
When specifying multiple `background-image`s, for example, Firefox will still just show a flash of white while loading the first one, and the fallback never seems to be used.
@joepie91 🙈 I should have pointed to https://developer.mozilla.org/en-US/docs/Web/CSS/image/image-set instead
it’s supported in all browsers as of 2023 (new to me!), but the front image on https://lobi.to/ is an older implementation that relies on z-index tricks to use <picture> as a background image
@unlobito Hmm. Assuming you're referring to the resolution selector, how does the browser select the resolution(s) to load?
@unlobito Right, yeah, my concern is specifically network speed rather than screen resolution, and loading a reduced-resolution version first (whether quality or resolution) works around that issue
@joepie91 i think we might be coming about this from different angles ^^;
i’m mostly thinking of resolution in a DPI sense, but i appreciate you might mean resolution in a photo quality sense
disappointingly, it seems there’s a gap in the CSS spec for explicitly signalling an image as only appropriate for high-bandwidth connections: https://github.com/whatwg/html/issues/4421
you could provide both PJPEG and webp for a given photo, but a browser might mistakenly pick the “slower” option :(