[whatwg] defer on style, depends

On Sun, Feb 15, 2009 at 9:54 AM, Boris Zbarsky <bzbarsky at mit.edu> wrote:
> Garrett Smith wrote:
>>>
>>> Because you have <script>s after your stylesheets, not just stylesheets.
>>>  Really, controlled experiments are hard.  You have to hold all but one
>>> variable constant.
>>
>> OK, I modified the example:
>>
>> http://localhost/jstest/block/link-img-noscript.html
>>
>> The bottom script will not load ('load' as opposed to 'run') in
>> Firefox/3.0.6 until after 5 seconds.
>
> Right.  Because you still have another script before it.
>

Yes, you are correct. It is the script that blocks the external script
from being requested; not the stylesheet. This has been changed in
3.1pre.

>> The result shows that example.js loads 5 seconds after the initial
>> page load. example.js waits for the stylesheet to load.
>
> It waits for the first script to execute, which waits for the stylesheet to
> load.  That's not quite the same thing.
>

Yes, thank you.

>> My concern is with the recomputation you mentioned. Can you elaborate
>> on that, or point me to a webpage that explains it?
>
> Well, once a new stylesheet loads you have to redo rule matching for all
> nodes that might be affected in the document.  In practice, I believe
> current UAs will rerun the rule matching algorithm on all nodes in the
> document.
>

I can see why rule matching would happen for all nodes in the document.

On what occasion(s) do(es) that algorithm run?

Aside: Could the CSS have a selector applied to it for sub-matches?
e.g. First find nodes in the document that match a selector value,
then match stylesheets rules that match the subset. So instead of:

.infoPanel table { }
.infoPanel table tr { }

it would be (pseudocode):
.infoPanel {
    table {}
    tr {}
}

Could such a strategy for rule-matching help performance, or would it
hinder performance or be too much work to maintain?

I know it is off topic, but the effect of rule matching would hurt performance.

>> Question: What does IE do?
>
> That's a really good question.  I don't have IE on hand to test with; do
> you?
>

LOL. No, I have only my mac at home. I need a new laptop with windows.
Does anyone reading have windows?

>>> Well, one option is to stop worrying about micromanaging the load order
>>> and
>>> assume that speculative parsing will solve your problems.... will it?
>>
>> Possibly. If the author could declare what a script depends on and let
>> the implementation determine what to load and when, would that be too
>> complicated?
>
> Too complicated for whom?  The author or the implementation?
>

I see a few edge cases. For example:
  A script depends on something that is never loaded.
  A script depends on something that is added to the document later.
  A script depends on an alternate stylesheet.

Reading <script depends="a"...></script> seems clear to me. Then
again, I stole the idea from ANT.

For the implementation, I do not actually know because I have not
worked on that code. What are your thoughts?

> -Boris
>

Garrett

Received on Sunday, 15 February 2009 13:15:49 UTC