Opened 11 years ago

Closed 11 years ago

#11544 closed defect (duplicate)

The Script Defer mechanism in IE for dojo's onload event breaks with flash objects on page

Reported by: Yousuf Haider Owned by: anonymous
Priority: high Milestone: tbd
Component: Core Version: 1.4.1
Keywords: addOnLoad onload defer flash Cc:
Blocked By: Blocking:


If you have :

  • an external JS file included in your page

  • a flash object included in the page

in IE the script defer mechanism breaks because deferred script is parsed before the external JS file has been parsed. This is a timing issue so it doesn't happen every time but happens often enough (and on some machines very regularly) to break Dojo's onLoad event mechanism.

The result is that functions attached using addOnLoad() get called before some external js files have been parsed. If the addOnLoad() functions depend on code in those files the page breaks.

Based on my discussion with James Burke on the mailing list external JS files should have been parsed before functions attached using addOnLoad() were called.

Removing the flash object from the page fixes the issue and dojo's onload is triggered at the correct point. (i.e after the external JS files have been parsed)

Happens in both IE 8 and 7.

Steps to reproduce:

  1. Download the attached files and copy them in a local web server.

  1. Open IE with Developer toolbar and open the Script console screen.

  1. The test structure is as follows:

  • The main page contains an IFrame.

  • The Iframe source file innerFrameWithFlash.html is a page with a flash video on it and, a defer script and an external JS file.

  1. Access the defer_test.html page. This page will run the script defer test 50 times by default and print the results in the console.

Since its a timing issue we run it multiple times in case the issue doesn't show up in one run. The expected output for all 50 cases should be:

" external.js parsed readystate complete".

However you will see that some of the runs will log this :
" readystate complete external.js parsed "
indicating that the defer script onreadystate=complete occured before the external JS was parsed.

  1. Now change the iframe's src attribute inside defer_test.html to be innerFrameSimple.html and reload the page.

The results will be :

" external.js parsed readystate complete".

which is what we expect.

This is a serious issue because it breaks the semantics of dojo's onload event. We discovered this issue in our product when a flash object was included on a page that was using Dojo extensively.

Attachments (2) (5.5 KB) - added by Yousuf Haider 11 years ago.
test to check breakage of script defer mechanism
dojo.js (87.3 KB) - added by James Burke 11 years ago.
Minified, built dojo.js from 1.4.1 release that includes the IE DOMContentLoaded fixes from #10918

Download all attachments as: .zip

Change History (5)

Changed 11 years ago by Yousuf Haider

Attachment: added

test to check breakage of script defer mechanism

comment:1 Changed 11 years ago by James Burke

Thank you for the detailed report. In Dojo 1.5 we moved away from the script defer mechanism to a check on a property that is only available after DOMContentLoaded. I backported the changes that ares listed in ticket #10918 that tracked the 1.5 changes. I will attach the modified, built 1.4.1 dojo.js file to this ticket.

Please try that version of Dojo in your app to see if that fixes the problem you see with the flash file. If it does, then we can mark the issue as fixed in 1.5.

Changed 11 years ago by James Burke

Attachment: dojo.js added

Minified, built dojo.js from 1.4.1 release that includes the IE DOMContentLoaded fixes from #10918

comment:2 in reply to:  1 Changed 11 years ago by Yousuf Haider

Replying to jburke:

I just tried the patched 1.4.1 dojo.js and it seems to have fixed this problem. Thanks for the response and fix.

comment:3 Changed 11 years ago by James Burke

Resolution: duplicate
Status: newclosed

Great, will close this as a duplicate of #10918

Note: See TracTickets for help on using tickets.