Bug 39455 - <link> elements with media queries that do not affect the current page can be delayed
Summary: <link> elements with media queries that do not affect the current page can be...
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Page Loading (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Enhancement
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-05-20 16:24 PDT by Joseph Pecoraro
Modified: 2012-10-11 16:36 PDT (History)
3 users (show)

See Also:


Attachments
[IMAGE] Web Inspector Shows Waiting for a useless media="print" resource (145.63 KB, image/png)
2010-05-20 16:24 PDT, Joseph Pecoraro
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Joseph Pecoraro 2010-05-20 16:24:07 PDT
Created attachment 56644 [details]
[IMAGE] Web Inspector Shows Waiting for a useless media="print" resource

HTML5 describes the <link> element's media attribute here:
http://www.whatwg.org/specs/web-apps/current-work/multipage/semantics.html#attr-link-media

> However, if the link is an external resource link, then the media attribute
> is prescriptive. The user agent must apply the external resource when the
> media attribute's value matches the environment and the other relevant
> conditions apply, and must not apply it otherwise.

If the browser is unaffected by the media queries in the <link media="...">
then it is safe to assume that the content is not immediately necessary
and time could be better spent download other resources. Also, it may
not be necessary to prevent the DOMContentReady or onload event's
for the resource.

In the attached image, the "print.css" file is a link with media="print". These
styles do not affect the document, yet it was downloaded and delayed some
events from firing.
Comment 1 Timothy Hatcher 2010-05-20 16:27:14 PDT
This also happens for type="alternate stylesheet".
Comment 2 Alexey Proskuryakov 2010-05-20 16:57:04 PDT
Firing load events before alternate stylesheets have loaded can easily have compatibility consequences - a script running from onload may want to switch stylesheets, for example. Even media="print" stylesheets are exposed via CSSOM.

Loading them after other resources sounds like a great idea to me.
Comment 3 Alexey Proskuryakov 2011-01-31 21:59:00 PST
Antti, is this fixed now?