W3C home > Mailing lists > Public > www-style@w3.org > February 2011

Re: Browsers downloaded linked files regardless of media type

From: Antony Kennedy <antony@silversquid.com>
Date: Sat, 12 Feb 2011 17:04:30 +0000
Cc: www-style@w3.org
Message-Id: <85F62264-A21B-41A0-8FBD-2B7E430625A7@silversquid.com>
To: Boris Zbarsky <bzbarsky@mit.edu>
I've now discovered that WebKit honours disabled="true" in the link tag.

	<link id="ss1" rel="stylesheet" href="test.css" disabled="true" type="text/css" >

You can then enable it whenever you like, and it will be immediately applied, like so:

	document.getElementById('ss1').disabled=false;

It does not appear in document.styleSheets. If it is enabled, and you disable via JS, it then disappears from the array.

When it is in the array (and enabled)  it does have a readable property for disabled.

This is not what I was asking for. It seems a sane idea, however and makes lazy loading of CSS (if there were a valid use case) very easy. It only works, as far as I can tell, for the link tag – which makes sense, since otherwise there is no way to hook in to the element to enable it again.

Just an FYI.

What I'm really after is for CSS that fails the media query to not be loaded at all. And to be able to defer CSS so it doesn't block rendering (print stylesheets in IE block rendering even if you link to them at the bottom of the page).

Since no-one seemed against these ideas, is there a way for me to propose them more formally? Is there a template document I could populate?

A

On 27 Jan 2011, at 03:31, Boris Zbarsky wrote:

> 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 Saturday, 12 February 2011 17:06:15 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 17:20:37 GMT