[Webkit-unassigned] [Bug 33018] New: load event fires before external scripts have executed

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Tue Dec 29 06:13:09 PST 2009


https://bugs.webkit.org/show_bug.cgi?id=33018

           Summary: load event fires before external scripts have executed
           Product: WebKit
           Version: 528+ (Nightly build)
          Platform: PC
        OS/Version: Linux
            Status: UNCONFIRMED
          Severity: Normal
          Priority: P2
         Component: Page Loading
        AssignedTo: webkit-unassigned at lists.webkit.org
        ReportedBy: marcus at better.se


Created an attachment (id=45598)
 --> (https://bugs.webkit.org/attachment.cgi?id=45598)
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

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list