by cbr · 11y ago · 0 comments
The download or file read operations can be stopped
as soon as sufficient detail is available, and if
needed, it can be resumed when for whatever reason
more detail is needed.
-- http://flif.info/responsive.php
Unfortunately that's not how HTTP works. Your browser opens several connections to a website, and makes requests for resources. Each connection is in use until that resource is fully loaded, at which point you can send a request for another resource up that connection. Yes, the browser could close the connection after it has received enough of the image for the desired quality, but there's a lot of overhead in setting up a new connection, including some round trips, and so that is probably a net loss.The JPEG image format also supports progressive images, in browsers today, and no one has figured out how to use that for single-file responsive images yet.
(You might be able to do something in HTTP/2 where you set the priority of the stream to 0 after you have enough of it for your needs, but I don't think anyone has gotten this working yet.)
<img src="foo.jpg">
Now, let's say foo.jpg is progressive, and if you examine the file you can see that you need H bytes for the header, N bytes for the first layer, M for the next, and so on. Then you could mark up the html as: <img src="foo.jpg"
bytes-1x="(H+N)"
bytes-2x="(H+N+M)" ...>
but that's a huge pain to generate by hand, and people like to compose html by hand.If we want something that can catch on, it needs to be something where browsers and servers can negotiate in a fully automated way. Or we can just use srcset/picture.