[whatwg] defer on style, depends

Garrett Smith dhtmlkitchen at gmail.com
Mon Feb 9 10:56:33 PST 2009

On Mon, Feb 9, 2009 at 9:42 AM, Boris Zbarsky <bzbarsky at mit.edu> wrote:
> Garrett Smith wrote:
>> The script's defer attribute does not work in a majority of
>> implementations. For such browsers, it makes sense to put the script
>> lower on the page for performance reasons, not before the linked
>> stylesheets. Moving the deferred script from the bottom of the page to
>> the head, just before the stylesheet would mean that those scripts
>> would load first. This would prevent the page content from loading
>> until those scripts had loaded. This would hurt performance in the
>> majority of browsers in use today.
>> Putting scripts at the bottom works in all browsers. Including a
>> linked stylesheet in the head causes delays.
> I'm not sure why you think that adding features to browsers to work around
> bugs in those same browsers is the right approach.  Would just fixing
> "defer" for scripts fix your issue?

There are two/three issues.
1) want to load stylesheets without having scripts block
2) want to load stylesheets later, (infoPanel example)
3) (2), but want to make sure the stylesheet is loaded before the script runs.

(1) <link independent ..> would address the problem.
There is no solution for (2) or (3). Current implementations may try
to parse the script and see if it can run, but such algorithms are
obviously not going to be effective.

In the example,  the document's title changes to bgColor=<something>.
Adding defer to the script does not help. In fact, it makes the
problem worse.

What happens is that the deferred script waits for the link to load,
but blocks content from loading. After the link loads, the script

Example 1:
<link independent type="text/css"  ...>
I want the browser to:
1) load my stylesheet and then immediately begin to load script in parallel.

Example 2
<link defer type="text/css" id="lateBoundCSS" ...>
<script depends="lateBoundCSS"...></script>
I want the browser to:
1) defer my linked stylesheet id="lateBoundCSS" until content is rendered
2) render content
3) upon encountering the deferred script, check the depends
4) upon finding Result(3) is "lateBoundCSS", wait for that resource to
finish load before running.

The infoPanel script needs the infoPanel.css stylesheet,
id="lateBoundCSS". The css is only related to that script, it is
useless otherwise.

The user might begin reading, use the search box, use the login box,
or click links in the page. There is no reason why infoPanel.css needs
to be loaded prior to the user doing those things.

>> Whatever.
> That's a very cogent and enlightening response, I'm sure, but it seems to be
> going over my head.  Care to explain in terms someone of my limited mental
> ability can understand?

Boris, you have snipped what I replied to (the part Ian wrote before I
wrote "whatever").

You replied to that out-of-context snip with a loaded question that
seems very sarcastic. I do not think it such sarcasm is appropriate. I
do not think it would be at all productive to answer such questions.



> -Boris

More information about the whatwg mailing list