W3C home > Mailing lists > Public > public-html@w3.org > October 2010

Re: Executing script-inserted external scripts in insertion order

From: Steven Roussey <sroussey@gmail.com>
Date: Fri, 29 Oct 2010 20:12:06 -0700
Message-ID: <AANLkTi=9BXtmt9CqfDTV_Zv36j-Pk6L6WcLQGmra2mnG@mail.gmail.com>
To: public html <public-html@w3.org>
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 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 9 May 2012 00:17:16 GMT