[whatwg] Spec for downloading stylesheets
Tab Atkins Jr.
jackalmage at gmail.com
Sat Jun 16 07:46:55 PDT 2012
On Sat, Jun 16, 2012 at 1:23 AM, Andy Davies <dajdavies at gmail.com> wrote:
> I'm under the impression that a UA has to download all stylesheets
> regardless of whether they will be used e.g. print, mediaquery may never
> match etc.
> I've had a crawl through the specs but can't find the behaviour specified.
> Is my understanding right and if so can someone point me at the relevant
The relevant spec is just HTML, which pays no attention to the @media
attribute when parsing <link rel=stylesheet>s. Without anything
explicitly saying "Don't download X unless condition Y is met", you
just download them all.
The reasoning for this is that the set of stylesheets that you need
for a document is not static - users *do* resize their browser, for
example, and browsers would like to apply the relevant CSS
immediately, not wait a second or so to kick off and finish a
download. It also lets us keep the invariant that, if you use
matchMedia or something to see if a MQ matches, all the styles are
correct for the state of the world as you see it.
More information about the whatwg