Re: Simplified source selection algorithm

On Monday, September 16, 2013 at 11:53 PM, Kornel Lesiński wrote:

>  
> In response to Simon Pieters' criticism that <source> selection algorithm  
> is too complex[1], I've drafted a simpler one:
>  
> https://github.com/ResponsiveImagesCG/picture-element/issues/62#issuecomment-24479164
Just a quick note that we've (the Editors) been thinking along the same lines (and I've got a hacked up version of the spec over in my repo that already does some of the above). It's also what I presented during the workshop (i.e. "we are getting rid of the kitchen sink!")
>  
> Simon finds this algorithm acceptable[2]. I'd like to hear your opinion  
> whether such solution is OK.

I thought his concern was more about having multiple elements … but anyway :)   
>  
> - Dependency on Media Element and <video>-like algorithm is gone. There's  
> no networkState property.

Agreed!   
>  
> - The algorithm picks the first <source> that matches. Matching is done  
> based on media and type attributes.

Agreed!   
>  
> - I haven't written that explicitly on github, but selected <source  
> src/srcset> is interpreted pretty much like copying of its attributes to  
> <img src/srcset>.

Yep. Note also that <picture> no longer has a src or srcset attribute.   

> - Browser will re-evaluate sources whenever conditions change (so if  
> device is rotated or window is resized a different source may be picked,  
> and different image may be loaded).

Agreed.   
>  
> - Choice is made asynchronously and atomically from JavaScript's  
> perspective (i.e. messing with <source> DOM elements won't change the  
> selected source until next event loop tick).

Nice. Had not talked about this in the spec yet - but we were thinking the same thing.   
> - If you use <source media> with media query that browser cannot evaluate  
> immediately (e.g. min-width: in an iframe that has no layout yet) browser  
> may delay fetching of the image until CSS is loaded.

Nice too :)  

 

Received on Tuesday, 17 September 2013 14:33:25 UTC