Or have a progressive image format. Wherein the smallest/lowest quality image is at the front of the file and is enhanced by loading more data of the same file.
It should be up to the browser and the image file format to determine the best option.
It should be up to the browser and the image file format to determine the best option.
Both Jasper support this (ilyrrates) and OpenJpeg (-r and -q) support this functionality.
<picture>
<source srcset="foo.jp2 100w 100h range=1-<first layer>">
<source srcset="foo.jp2 500w 500h range=1-<middle>">
<source srcset="foo.jp2 1000w 1000h">
</picture>
That'd avoid the need to a round trip at all and it'd also be a huge improvement for caches which support HTTP range correctly since it'd be a single resource rather than multiple different URLs. It'd also allow browsers to start making decisions like selectively preloading more of an image which the user is likely to zoom, etc. although some of that would come simply from a good progressive JP2 implementation.That's largely opinion: are byte ranges really better than having to maintain clusters of related images? Any serious site already has to deal with things like cache invalidation when a source file changes and by the scale of things which sites do for performance this is certainly no worse than, say, JavaScript/CSS minification or UA sniffing.