Re: Media Query Variables

On Fri, 13 Sep 2013 11:08:21 +0200, Kornel Lesiński <kornel@geekhood.net>  
wrote:

> The algorithm is reliable in all cases, since the browser will have to  
> re-run image selection algorithm when media query changes (just like it  
> would when window size changes on viewport-based query).

Sure.

> That case is suboptimal from performance perspective, since the last  
> variant may be unnecessarily preloaded, but this wouldn't break the page.

The performance problem is my concern.

> It can be solved in two ways
>
> 1. educate authors about performance best practices suggesting vars in  
> <style> or a var() on all options. Education is hard and not all authors  
> will get it, but if the spec introduces feature as intended for <style>  
> only maybe even w3schools will copy right advice ;)

This doesn't solve the problem. We should not add an ability to browsers  
that we don't want people to use. The only way to make people not use  
something is to not support it.

We could have the at-rule but only support it in <style>, but that gives  
the expectation that it also works in external stylesheets. Maybe that's a  
good thing if we want to allow it in <style scoped> (and have it scoped).

> 2. Browsers can postpone loading of the image when preload scanner  
> encounters an unknown variable.

Making the image load block on external stylesheets is not acceptable. I  
think we should design a solution that enables the browser to download the  
correct resource as soon as it sees it without blocking on another  
resource.

> The worst case of misuse is bandwidth waste. The right image will be  
> displayed regardless - picture is not like video where you have to make  
> the choice once and do it perfectly first time. It allows browsers to  
> reevaluate options when conditions change.

I think it is important to make the right choice for images on page load.

Do you want this proposal to have no effect for <video><source media>? How  
about <link rel=stylesheet media>?

-- 
Simon Pieters
Opera Software

Received on Friday, 13 September 2013 10:19:02 UTC