Re: Executing script-inserted external scripts in insertion order

On Thu, 21 Oct 2010 17:13:50 +0900, Adam Barth <w3c@adambarth.com> replied  
to Henri Sivonen:

>> 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 see the point about explicity. Setting '.async=false' seems pretty  
understandable to authors who understand what <script async> does, but if  
I try thinking as an author it's not really obvious what script to set  
async on. Async=false would mean "make sure any scripts added to the DOM  
before this one have executed before trying to execute this script", or  
"make sure this script is executed before those I add afterwards"?

I actually like your document.executeScrips() proposal, it takes the use  
case LABjs demonstrates a demand for and ensures there is a built-in API  
that's easy enough sites can use it without requiring helper scripts. The  
counter-argument is feature creep..

Regarding the issues with the proposed use of async, would it help if we  
moved the feature detection away from the proposed  
"document.createElement('script').async==true", for example to  
HTMLScriptElement.defaultAsync ? Would it help if we specified @async as  
an enumerated attribute with values "true" and "false"? Example code to  
add a script through DOM and mark it as ordered

var orderedScript=document.createElement('script');
orderedScript.src='foo.js';
if( HTMLScriptElement.defaultAsync ){
     orderedScript.setAttribute('async', 'false');
}


-- 
Hallvord R. M. Steen, Core Tester, Opera Software
http://www.opera.com http://my.opera.com/hallvors/

Received on Monday, 25 October 2010 02:29:05 UTC