Bug 33018

Summary: load event fires before external scripts have executed
Product: WebKit Reporter: Marcus Better <marcus>
Component: Page LoadingAssignee: Nobody <webkit-unassigned>
Status: RESOLVED DUPLICATE    
Severity: Normal CC: ap
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: PC   
OS: Linux   
Attachments:
Description Flags
test case - inline script which adds a script tag
none
the external script (one-liner) referenced by the test case none

Marcus Better
Reported 2009-12-29 06:13:08 PST
Created attachment 45598 [details] test case - inline script which adds a script tag If a script inserts another script tag having a src attribute through a DOM appendChild call, that second script will not run until after the document load event has fired, and after other scripts in the HEAD or BODY have executed. This causes problems when scripts included later in the document have dependencies on the dynamically loaded script, which is typically the case with JavaScript libraries that the page needs. This deviates from Firefox 3.5 behaviour. I suspect it may also conflict with the WHATWG draft [1] which seems to require that a script must be run synchronously when its script element is inserted. See the attached test case, in which an inline script inserts another script tag for an external file. Running the test case in Chrome 4.0.266.0 (WebKit 532.6) or Arora 0.10.1 (WebKit 532.4) on Linux gives this console output: inline HEAD adding script inline HEAD 2 inline BODY body load a executed We can see that the "a executed" output from the external script was deferred to the end, although the script was added at "adding script". In contrast, Firefox 3.5 Linux gives this order: inline HEAD adding script a executed inline HEAD 2 inline BODY body load (Another amusing fact is that the picture changes if the external script is inserted with document.write instead of the DOM method. In that case, WebKit behaves identically to Firefox. I have a bunch of different test cases for various other ways of nesting the script inclusions.) [1] http://www.whatwg.org/specs/web-apps/current-work/#script
Attachments
test case - inline script which adds a script tag (600 bytes, text/html)
2009-12-29 06:13 PST, Marcus Better
no flags
the external script (one-liner) referenced by the test case (27 bytes, application/x-javascript)
2009-12-29 06:14 PST, Marcus Better
no flags
Marcus Better
Comment 1 2009-12-29 06:14:15 PST
Created attachment 45600 [details] the external script (one-liner) referenced by the test case
Alexey Proskuryakov
Comment 2 2009-12-29 22:22:25 PST
*** This bug has been marked as a duplicate of bug 28783 ***
Note You need to log in before you can comment on or make changes to this bug.