Preferred solutions for responsive images
Scott Jehl recently tweeted:
I concur. A couple of months ago, I asked what you preferred as a solution for responsive images. At the time, I didn’t have a strong opinion. But over the last couple of weeks, I’ve become increasingly comfortable with a direction that Scott Jehl, Ethan Marcotte and I discussed on twitter recently.
Short run solution: preparse attribute
In September, Scott Jehl proposed a solution that might be fairly easy for browser makers to implement in the short run: adding a preparse attribute to the script tag.
One of the other suggestions for solving this was for browsers to standardize on how they load assets. I don’t like that idea because it prevents browsers from experimenting on ways to parse pages and load assets more quickly.
Long run solution: improvements to img tag
Therefore, I would like to see one of these two improvements to the img tag:
<source src="butterfly-small.png" media="max-device-width:480px" />
<source src="butterfly-large.png" media="min-device-width:481px" />
This is my preferred option, but I’m unclear on how older browsers would handle an image tag that contains child elements.
media-xs="(min-device-width:320px and max-device-width:640px)"
media-m="(min-device-width:640px and max-device-width:1024px)"
Why not headers?
I would love the browser to send more data to the server about the device making the request, but I don’t think servers should be necessary for the image tag to work in a responsive design.
I also think there is a decent chance that screen size is just the first of many headers we’d like the browser to send along. I don’t want to open up pandora’s box, but it would be nice to get something that felt more like a comprehensive solution instead of a bandaid.
Why not a different, progressive image format?
I’d love this, but feel wholly unqualified to judge what it would take. I’m not sure how long something like that would take to implement and what sort of patent minefield might lie there.
So let’s start with the preparse attribute
Unless someone points a major flaw with the preparse idea, I’m going to submit it as a feature request to the appropriate people to get the ball rolling.
Which reminds me, does anyone know where I should start? :-)