Re: Browsers downloaded linked files regardless of media type

I understand the races issue. And that it would be exposed. And the "something". :)

Deferring loading of stylesheets would be desirable for, for example, print stylesheets – where the user definitely does not need them on page load. Using JavaScript to defer the CSS until after everything else has loaded, but creates a JS dependency which I wouldn't be keen on.

How about something like:

<link rel="stylesheet" href="test.css" media="boat" autoload="false" />

and:

@import url(test.css) boat autoload-false;

…and defaulting to true in both cases? Or something similar.

In these cases, the author would have to understand that these stylesheets would not be exposed to the CSSOM or document.styleSheets. I'm unclear on how authors could misuse this.

People *would* use screen/handheld for performance if the browsers knew not to download them if unnecessary! A screen stylesheet is typically going to be larger than the handheld counterpart.

"Necessary" would be upon a query to document.styleSheets or the CSSOM. The implications of this are considerable, so I'm happy for us to discount this suggestion.

On 26 Jan 2011, at 18:29, Boris Zbarsky wrote:

> On 1/26/11 8:59 PM, Antony Kennedy wrote:
>> Dynamic changing of the media is of course possible, but it seems completely appropriate to choose not to download the file until it applies.
> 
> The problem is that downloading is asynchronous.  So this introduces races.
> 
> And again, the stylesheet is exposed to the CSSOM.  Not loading it means either not exposing it or lying about the objects or ... something.
> 
>> In fact, this would make it very easy to defer loading of stylesheets
> 
> Why would this be desirable?
> 
>> Should there not be a way to avoid this unnecessary download and the performance hit it implies?
> 
> Perhaps.  Would you trust authors not to misuse it?
> 
> I could live with an opt-in "don't load this sheet if you don't support its medium" attribute.  It would need some careful defining in the face of media queries...
> 
>> Why write a screen stylesheet and a handheld one for performance
> 
> I don't know.  Do people do that "for performance"?  Last I checked this was mostly done because the form factor is very different....
> 
>> Perhaps only download files as necessary
> 
> Define "necessary"?
> 
> -Boris
> 

Received on Thursday, 27 January 2011 03:25:19 UTC