[whatwg] Spec for downloading stylesheets
dajdavies at gmail.com
Sat Jun 16 12:01:07 PDT 2012
I presume it's this -
"For external resources that are represented in the DOM (for example,
style sheets), the DOM representation must be made available even if
the resource is not applied. To obtain the resource, the user agent
must run the following steps:
If the href attribute's value is the empty string, then abort these steps.
Resolve the URL given by the href attribute, relative to the element.
If the previous step fails, then abort these steps.
Fetch the resulting absolute URL.
User agents may opt to only try to obtain such resources when they are
needed, instead of pro-actively fetching all the external resources
that are not applied."
On 16 June 2012 15:46, Tab Atkins Jr. <jackalmage at gmail.com> wrote:
> 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