Did you know? DZone has great portals for Python, Cloud, NoSQL, and HTML5!
HTML5 Zone is brought to you in partnership with:

John Esposito curates content at DZone, while writing a dissertation on ancient Greek philosophy and raising two cats. In a previous life he was a database developer and network administrator. John is a DZone Zone Leader and has posted 268 posts at DZone. You can read more from them at their website. View Full User Profile

Save Bandwidth, Be Responsive! The New Responsive Images Community Group at W3C

02.21.2012
Email
Views: 1591
  • submit to reddit
The HTML5 Microzone is presented by DZone and Microsoft to bring you the most interesting and relevant content on emerging web standards.  Experience all that the HTML5 Microzone has to offer on our homepage and check out the cutting edge web development tutorials on Script Junkie, Build My Pinned Site, and the HTML5 DevCenter.

Earlier this month a post appeared on the whatwg discussion list, proposing a pie-in-the-sky-ish modification to (presumably HTTP, or maybe SPDY) standards: 'let browsers report device capabilities in a request header'.

Right, makes sense, the light-bulbs go off: why download the high-res image at all, when the client viewport is only 480 pixels wide?

Responsive design with CSS and JavaScript only controls the client, of course, so the server still needs to spit out way more data than the client can ever display. And then the JavaScript says, 'No, do not display this data. Display that data instead.' But both requests still went through, and both files were still streamed from the webserver to the client.

Massive waste, observed the original post. And the proposal was simple, but touched off a huge, passionate discussion -- roughly divided into the 'Sweet, that would save SO much bandwidth, and so many client-side cycles!' and 'No, adding info to the HTTP request header is pretty much always a bad idea: remember Accept-Charset?'

Then Mathew Marquis jumped in with an 'I'm late to the conversation' and steered the conversation toward responsive images, a clever, HTML5-media-inspired idea that never quite got off the ground -- until this week.

Thanks to this conversation, a new Community Group sprung up at W3C: the Responsive Images Community Group, whose homepage asserts:

Our goal is a markup-based means of delivering alternate image sources based on device capabilities, to prevent wasted bandwidth and optimize display for both screen and print.


Mathew Marquis was selected to chair the group, and quickly wrote a great summary of the discussion. Web developers will love his emphasis on usability, with a proposed markup like this:

<picture alt="Alt tag should accurately describe the image represented by all sources, though cropping and zooming may differ.">
<source src="mobile.jpg" /> <!-- Matches by default. --> 
<source src="high-res.jpg" media="min-width: 800px" /> <!-- Overrides the previous source over 800px before any assets are fetched, resulting in a single request. --> 
<img src="mobile.jpg" /> <!-- Fallback content, in the event the <picture> tag is completely unsupported by the user’s browser. --> </picture>

Turns out this idea has been percolating on and off for some time (explains Mathew). But now there's a Community Group, and now even a sample implementation -- polyfill for a feature that doesn't yet exist!

If you're a web developer interested in responsive design, and want something more powerful and less wasteful than current options, then seriously consider contributing to the Community Group discussion. This is an opportunity to do something really cool for the web, something that could really benefit web developers (not to mention infrastructure engineers!) for years to come.

Published at DZone with permission of its author, John Esposito.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)

HTML5 is the most dramatic step in the evolution of web standards. It incorporates features such as geolocation, video playback and drag-and-drop. HTML5 allows developers to create rich internet applications without the need for third party APIs and browser plug-ins.  Under the banner of HTML5, modern web standards such as CSS3, SVG, XHR2, WebSockets, IndexedDB, and AppCache are pushing the boundaries for what a browser can achieve using web standards.  This Microzone is supported by Microsoft, and it will delve into the intricacies of using these new web technologies and teach you how to make your websites compatible with all of the modern browsers.