Re: Executing script-inserted external scripts in insertion order

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.

> > 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.

> >  * 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.

> >  * 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).

-- 
Henri Sivonen
hsivonen@iki.fi
http://hsivonen.iki.fi/

Received on Thursday, 21 October 2010 07:53:06 UTC