W3C home > Mailing lists > Public > whatwg@whatwg.org > May 2012

Re: [whatwg] Implementation complexity with elements vs an attribute (responsive images)

From: Mathew Marquis <mat@matmarquis.com>
Date: Sat, 12 May 2012 10:49:36 -0400
Message-Id: <707F1D20-D061-428F-B5E8-98E627636F05@matmarquis.com>
To: whatwg@whatwg.org

On May 12, 2012, at 10:36 AM, James Graham wrote:

> 
> 
> On Sat, 12 May 2012, Mathew Marquis wrote:
> 
>> While that information may be available at the time the img tag is parsed, I donít believe it will be available at the time of prefetching ó Iím happy to research this further and report back with citations.
> 
> I am very confused about what you are claiming here. I have difficulty imagining any scheme that would make prefetching work worse with an attribute than with multiple elements. As Simon says there is a lot more that can go wrong in the multiple-element case because a single attribute can be processed atomically, but multiple elements can have all sorts of other junk between them that makes naieve processing (of a type likely to be used when prefetching) more likely to go wrong e.g.
> 
> <picture>
> <img src="foo">
> <script>document.write("</picture>")</script>
> <source src="bar">
> </picture>
> 

I think we can safely assume that any developer responsible for the above code likely wonít blame the element itself when it produces undesirable results. I assume such a pattern applies to the video and audio elements as well, and Iíve yet to see any developers declare them failures because they accidentally wrote a script that injects half a <marquee> tag in there. 

However, given a completely foreign and somewhat puzzling new syntax, I think itís far more likely weíll see the following:

<img src="face-600-200@1.jpeg" alt=""
        set="face-600-200@1.jpeg 600w 1x,
             face-600-200@2.jpeg 600w 2x,
             face-icon.png       200w">

Become:

<img src="face-600-200@1.jpeg" alt=""
        set="face-600-200@1.jpeg 600 1x,
             face-600-200@2.jpeg 600 2x,
             face-icon.png       200">

Or:

<img src="face-600-200@1.jpeg" alt=""
        set="face-600-200@1.jpeg, 600w 1x
             face-600-200@2.jpeeg 600w 2x,
             face-icon.png       200w">

Regardless of how gracefully the above fail by comparison to a developer _purposefully injecting a closing tag into an element_, Iím confident this is a far more likely scenario and a ďspot the differencesĒ game very few developers will be excited to play.
Received on Saturday, 12 May 2012 14:50:08 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 30 January 2013 18:48:08 GMT