The picture element: complexity

The design using multiple elements makes the implementation much more  
complex compared to a design using a single element. I've mentioned this  
before [1].

<source> for <video> and <audio> is also too complex. My experience with  
quality assurance for <video> at Opera suggests that <source> is a mistake  
that we should not repeat. There are too many edge cases. If I had  
realized this before it shipped in browsers I would have argued that  
<video> be changed to not use <source> elements, but now we're stuck with  

The argument against this I usually get is that the Priority of  
Constituencies design principle says that the needs of authors should win  
over the needs of implementors. However, this design principle needs to be  
considered together with the rest of the design principles, in particular  
in this case Avoid Needless Complexity [2]. In the case of resource  
selection using one element vs. using multiple elements, I would argue  
that the latter is about an order of magnitude more complex in the  
implementation and the needed tests because it enables more edge cases  
that simply cannot happen when you only have one element.

To illustrate my point, I have submitted some of the tests I've written  
for media elements' resource selection algorithm which test for a few of  
these edge cases.

(If you have comments on the tests, please use , thanks!)

So for instance a test like  
wouldn't be a possible case to test if it was a single element.

With this in mind, my recommendation is to make it a requirement for the  
solution to responsive images to use a single element, <img>. You can use  
a single attribute or multiple attributes to address the various use  
cases, that doesn't make a significant difference to the complexity.

Simon Pieters
Opera Software

Received on Thursday, 12 September 2013 10:19:54 UTC