Re: Browsers downloaded linked files regardless of media type

On 1/26/11 10:23 PM, Antony Kennedy wrote:
> Deferring loading of stylesheets would be desirable for, for example, print stylesheets – where the user definitely does not need them on page load.

See, that's a good example of where deferring is NOT a good idea.  It 
seems like one at first, from a web developer perspective, but think 
about it from a user perspective.

Say I load a page.  Then I want to print it.  I want my browser to 
print, not start contacting servers and downloading stylesheets.  I 
especially don't want this to happen if I am no longer connected to a 
network.

> Using JavaScript to defer the CSS until after everything else has loaded

The _prioritization_ of the loads is a separate issue entirely.  But 
note that last I checked the HTML5 spec in fact requires that such 
sheets be loaded, independent of media, before any scripts that come 
after the sheet can run...  Perhaps that needs to be changed.

> 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.

Right, that's what I said I could live with.

> 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.

Oh, easily.  Set it (e.g. by copy-paste from somewhere else), and don't 
test in a browser that actually supports the attribute.  Authors do that 
sort of thing all the time.

> "Necessary" would be upon a query to document.styleSheets or the CSSOM

If that happens, it's too late.  You can't hit the network and load a 
stylesheet at that point.  Your only options are to have the data, fake 
it, or throw an exception.

-Boris

Received on Thursday, 27 January 2011 03:32:30 UTC