Skip to content

Instantly share code, notes, and snippets.

@unscriptable
Created March 14, 2011 21:22
Show Gist options
  • Save unscriptable/869917 to your computer and use it in GitHub Desktop.
Save unscriptable/869917 to your computer and use it in GitHub Desktop.
Opera doesn't fire load events in the same order as the scripts are loaded
Firefox:
script1 executes
script1 fires load event
script2 executes
script2 fires load event
script3 executes
script3 fires load event
Opera:
script1 executes
script2 executes
script2 fires load event
script1 fires load event
script3 executes
script3 fires load event
Chrome and Safari work like Firefox.
IE does something different, but is similarly predictable as Firefox.
@unscriptable
Copy link
Author

the scripts aren't necessarily loaded in order as it looks in this gist, but their corresponding load events fire immediately afterward -- except in opera.

RequireJS uses addEventListener. I am wondering if i switch the code to use addEventListener() instead of onload if it will just start working.

Interestingly, IE9 behaves similarly to Opera when using addEventListener(). James Burke put in a ticket with the IE9 team, but they haven't responded. So James is testing for attachEvent() first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment