W3C home > Mailing lists > Public > public-respimg@w3.org > September 2013

Simplified source selection algorithm

From: Kornel Lesiński <kornel@geekhood.net>
Date: Mon, 16 Sep 2013 23:53:21 +0100
To: public-respimg@w3.org
Message-ID: <op.w3i0i7u8te2ec8@aimac.local>

In response to Simon Pieters' criticism that <source> selection algorithm  
is too complex[1], I've drafted a simpler one:


Simon finds this algorithm acceptable[2]. I'd like to hear your opinion  
whether such solution is OK.

  - Dependency on Media Element and <video>-like algorithm is gone. There's  
no networkState property.

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

  - 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>.

  - 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).

  - 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).

  - 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.

regards, Kornel

[1] http://lists.w3.org/Archives/Public/public-html/2013Sep/0137.html
[2] http://lists.w3.org/Archives/Public/public-html/2013Sep/0185.html
Received on Monday, 16 September 2013 22:53:53 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 20:12:40 UTC