Re: Media Queries and optimizing what data gets transferred

On Fri, Jan 25, 2013 at 4:20 AM, Henri Sivonen <hsivonen@iki.fi> wrote:
> Thus I propose that Media Queries gain a way to be flagged as
> evaluated only at page load time such that the browser promises to the
> Web author that it won't eagerly download data that's not applicable
> in the state the browser is in during the page load.

I've heard several suggestions that we allow a stylesheet to be marked
as "non-essential", so it doesn't block script loads or the document's
load event.  Usually the suggestion is in the form of adding an
"async" or "defer" attribute to <link> (I never learned which did what
in <script>, so choose whichever seems closer to the desired intent).

Perhaps we could hook your desired functionality into this as well?
Async stylesheets don't load at all *until* their media query
evaluates to true, and they never block other loads.  The default MQ
is just "all", so "async" by itself will just shift the stylesheet
down in load order, but if you apply a non-trivial MQ, it'll avoid
loading entirely until it's ready.

~TJ

Received on Friday, 25 January 2013 17:51:07 UTC