Live data from Hacker News

First draft of HTML img srcset for responsive images

whatwg.org

51–60 of 79 posts

Re: First draft of HTML img srcset for responsive images

#51

Earlier quoted context omitted.

That is a very appealing design, but sadly it doesn't address all the use cases. In particular one thing that people want to be able to do is to display a different image depending on the viewport dimensions, for example a closer crop on a small screen compared to that shown on a larger screen.

what is stopping this approach from addressing that use case?

No file format exists which supports this use case.

Re: First draft of HTML img srcset for responsive images

#52
post #19

Earlier quoted context omitted.

No, this won't work in the wild. It breaks caching completely. It requires scripting just to serve an image. The same url can have different data - imagine if you resume downloading a file, only to suddenly have a different file.

I disagree. Caches would have to be intelligent. Remember they already have to pay attention to language headers etc. URLs represent a conceptual resource, rather than a single file.

Part of the problem here is that there are a wide range of pixel densities. The server could choose to display the same image for some range of values but trying to get a caching proxy to sort this out is highly nontrivial.

Re: First draft of HTML img srcset for responsive images

#54

Earlier quoted context omitted.

what is stopping this approach from addressing that use case?

No file format exists which supports this use case.

I wasn't aware that you could specify completely different images at different resolutions.

Re: First draft of HTML img srcset for responsive images

#55

Earlier quoted context omitted.

what is stopping this approach from addressing that use case?

No file format exists which supports this use case.

We switched slightly midstream and we are now talking about an "entirely server side solution", if you scan back a few posts up. It's fairly trivial to do image processing on a server and cache the results based on the URL

Re: First draft of HTML img srcset for responsive images

#57

I believe this should be moved to the stylesheet. We already have ways to determine media/viewport/device/orientation etc so adding different imgs would be a no brainer. Bonus point, less cluttered HTML.

That would mean the browser couldn't start downloading any image before it had downloaded and parsed the stylesheet. Or that it would download all images and the entire point of saving bandwidth is lost.

Re: First draft of HTML img srcset for responsive images

#58

Earlier quoted context omitted.

Using CSS means you have to specify image locations in two places, with potentially different base URLs. Using Javascript means you have to load scripts before the img tag, which can hurt performance. Using http headers or a special URL format makes working with CDNs more difficult. This is actually a tricky problem to solve and it looks like the authors have considered some of the above problems. (I still hope they…

wait hold on how does having a query string in a url make CDN's more difficult?

You would need to turn on caching on your query strings in order for this idea to be useful with a cdn (ie, both http://example.org/image.png?size=big and http://example.org/image.png?size=small would need to be cached by the cdn). The issue is if you use some sort of user tracking, or rss feed, or anything that appends unique data to the end of the URL (so http://example.org/image.png?size=small could become something like http://example.org/image.png?size=small&user=19hv839&#38...). At that point, every single person is getting the uncached version of the site, since their unique url was never cached before. Its not difficult to configure this sort of thing by any stretch of the imagination, but it does add another step.

Re: First draft of HTML img srcset for responsive images

#59

This is silly and makes things way more complicated than they need to be. We have HTML tags, to which we can apply attributes directly via blah=blah syntax Or we can add attributes by making a style attribute, and using css syntax inside of it. Or we can have a space separated list of class names, and have attributes applied to an element externally by a CSS stylesheet. Or we can have an ID, and apply attributes usin…

most of your suggested alternatives are worse
Post reply on HN