[whatwg] Proposal for separating script downloads and execution

On 2/8/11, Boris Zbarsky <bzbarsky at mit.edu> wrote:
> On 2/8/11 11:04 PM, Kyle Simpson wrote:
[...]
>
> Now you may be right that authors who really want to screw up like that
> will just do browser-sniffing hacks of various sorts and still screw up.
>   But it's not clear to me that we need to make the barrier to shooting
> yourself in the foot lower as a result....
>
Newer browsers will parse and execute scripts faster. If a new
degrading script execute method is created and then an app wants to
use that to be snappier, then it will have to fall back to an older
browser that doesn't have that feature. The performance in that older
browser will be slower for two reasons.

But it wouldn't be hard to imagine:

if(typeof testScript.execute == "function") {
 // supports deferred execution.
}

>> I am not sure that I'm asking specifically to give a web author the
>> ability to "forbid" a browser from doing something. I think I'm asking
>> for something slightly less militant. I'm asking for the web author to
>> have a way to opt-out of normal default behavior (which is that a script
>> downloads, parses, and executes all together practically without
>> interruption)
>
> That's not quite true; the download is completely independent of the
> parse and execute in pretty much any modern browser.
>
>> and instead have some way to pause that process after
>> download and then resume it at a later time.
>
> In other words, forbid the browser to start parsing the script, right?
> How would you tell whether a browser implemented this as specified?
>
Add a "disabled" script that sets a flag and check to see if the flag
was set. If the flag wasn't set then the feature works.
[...]
>
> OK.  I definitely agree that better user control over when script
> _executes_ is a good idea.  Sounds like we're on the same page there.
>
Agreed. A more refined load/execute model is in order. This issue has
come up a before a few times over the past 5 years, including in
"defer on style, depends" (though not exactly on point, the examples
show how existing solutions don'[t work) and by David Anderson, who
IIRC proposed the "execute" method exactly.
--
Garrett

Received on Friday, 11 February 2011 09:36:08 UTC