Re: The lazyload and postpone attribute for images

On Thu, 26 Sep 2013 21:42:26 +0100, Marcos Caceres <w3c@marcosc.com> wrote:

>> If you define tablet/desktop variables in <style> in <head>, then  
>> preload
>> scanner will see them and know which one matches and load the right  
>> image
>> ASAP, but if you prefer you can define those variables in an external
>> stylesheet. Neither will match until CSS is loaded, so you don't have
>> double-download — It'll automatically postpone as long as necessary.
>
> Nice… though having to put this in the head has its drawbacks (e.g., you  
> lose cachability across your app as there is no external resource, at  
> least on first load) - though it might be worth it to get good  
> performance.

The declaration is short enough that sending it on every request is a  
non-issue from bandwidth perspective, it's just a matter of  
convenience/maintainability (if breakpoints change you want to update one  
file, rather than hunt down all copies in all HTML files).

> If you add them to the head, and then override them in an external  
> stylesheet, would the browser need to reevaluate all the variables?

Yes, the UA will re-evaluate queries using those variables. Having them in  
both HTML and external CSS is a bad idea — if they get out of sync you  
might have wasted downloads.

If you overwrite them with exactly same values then nothing (observable)  
will happen.

> Please keep us informed if the CSS WG agrees with the variables proposal.

I think there's agreement about everything except whether definitions in  
external CSS should be allowed (with risk of performance penalty), or  
whether <meta> should be used for MQ variables to make that impossible  
(which IMHO forces compromise for performance on sites that may not even  
need it, e.g. offline magazine or JS-only app).

-- 
regards, Kornel

Received on Thursday, 26 September 2013 21:56:02 UTC