Re: Executing script-inserted external scripts in insertion order

Just adding a (somewhat) tangential note:

In the discussion of script inserted script elements, assuming we were
at a point where (all) browsers loaded scripts independently of each
other, I think there is another solution for dependent script loading:
adding them together. Let me explain: If you added four script tags A,
B, C, D, then all four would be loaded at the same time and the first
one done runs first. If you had dependencies such that B relied on A
etc, noted as following: A->B and the same with C and D: C->D, then it
makes sense to me that instead of adding them one at a time (four
inserts into the documents DOM), that you could instead create two
DIVs with two scripts each:

DIV 1
-- SCRIPT A
-- SCRIPT B

DIV 2
-- SCRIPT C
-- SCRIPT D

Then insert DIV 1 and DIV 2 into the document. Thus, scripts "added to
the DOM at the same time" (via the insert of the parent DIV) would
execute serially. In the above case the user agent could load all four
at the essentially the same time, but will execute A before B and C
before D.

>From a web-dev point of view this is easy to grasp and easy to implement.


Steven Roussey

Received on Saturday, 30 October 2010 03:12:59 UTC