Re: Executing script-inserted external scripts in insertion order

On Thu, Oct 21, 2010 at 12:52 AM, Henri Sivonen <hsivonen@iki.fi> wrote:
> Adam Barth wrote:
>> > So in order to avoid adding one script execution queue, you propose
>> > adding an arbitrary number?
>>
>> Yes.
>
> Could you elaborate on why you chose infinity of ordered queues instead of one ordered queue? It seems to me that the Zero One Infinity rule leaves one as another reasonable number of ordered queues.

Because this mechanism is explicit.  Instead of having a secret queue
that most folks won't know is there and is subtly different in
different versions of browsers, it's clear what the author wants from
this mechanism.

>> > I can see issues with executing scripts without script elements:
>> >  * How does one register an onload or an onerror handler? I'd expect
>> >  JS libraries that currently provide script loader APIs not to want
>> >  to lose the ability to register onload or onerror handlers.
>>
>> Alternatively, one could structure the API more like XMLHttpRequest
>> and return a ScriptLoader object with various methods.
>
> That seems like pretty serious complexity creep compared to what Kyle was asking for to address his use case.

I'm not super excited about any of these proposals.

>> >  * What value would document.currentScript have when a script loaded
>> >  via document.executeScripts is executing?
>>
>> What values does document.currentScript have when running setTimeout
>> or an event handler?
>
> For asynchronous events and timouts, null typically, but I'm not entirely sure if nested event loops make it possible to reach a non-null currentScript from a timeout. For synchronous events, currentScript can be a script element if the script element is being evaluated and the event fires synchronously during the evaluation.

That seems fine for this API.

>> >  * Would onbeforescriptexecute and onafterescriptexecute handlers be
>> >  supported? If yes, how would one register the handlers and what
>> >  would the .target property of the event objects be?
>>
>> I'm not familiar with these events. Are they part of HTML5?
>
> They aren't part of the spec (at least not yet).

Adam

Received on Thursday, 21 October 2010 08:14:56 UTC