On Thu, 08 Sep 2011 22:57:25 +0200, Ian Hickson <i...@hixie.ch> wrote:
On Thu, 8 Sep 2011, Hallvord R. M. Steen wrote:
in our experience firing both load and readystatechange
events on SCRIPT will be painful. I suggest removing the latter again.
Interesting. We added it for compatibility reasons!
Do you have any examples of pages that do this so I could study them?
Many of those we've had trouble with have been updated and fixed, it seems
(we've contacted several of them to recommend changes). I'll include a
good amount of information below regarding the problems we found in the
past:
* http://www.hotmail.com - banner shown twice on login page
Caused by stuff like this (still seen in
https://secure.shared.live.com/~Live.SiteContent.ID/~16.1.16/~/~/~/~/js/WLWorkflow.js
):
EVENT.add(a,EVENT.Name.OnReadyStateChange,a.addEventHandler(ScriptLoader.evt_readystatechange));EVENT.add(a,EVENT.Name.OnLoad,a.addEventHandler(ScriptLoader.evt_onload));
but it's no longer a problem since they have added a _loaded property to
the SCRIPT to make sure the handler only runs once, and now do:
(a.readyState=="complete"||a.readyState=="loaded")&&!a._loaded
Needless to say, if they repeat the pattern elsewhere without the
workaround we'll be in trouble again.
* Bing Advanced Search Box not work with Opera
Bing's search field embedded on third-party site did not work. Bing does
no longer provide such a service to webmasters, and the handful of sites
we knew about that used Bing search have switched to other providers, but
here's my description of the problem: "They keep a global counter of how
many scripts have loaded. If all expected ones have loaded they try to
call the search box script ready function. However, since they define both
onreadystatechange and onload and we fire both, the counter increments
twice as fast as they expect and they call the function before they've
loaded the script."
* Google Maps on Tripadvisor.com not interactive in Opera
This also seems fixed, here's the analysis: "the script isn't prepared for
a browser that supports both onload and readystatechange on SCRIPT, it
ends up adding the main Google Maps file twice, and the double callback
from the Maps code confuses things. (It's the readystatechange for
http://c1.tacdn.com/js3/ta-maps-c-v2524033128a.js that causes double
append etc.)"
* Broken Facebook app "Are YOU Interested?"
This app called into Facebook's API in a way that caused problems. This
too seems to work now, but the underlying problem in Facebook's JS is
still there. I guess it's a matter of chance and luck whether Facebook
functionality that uses this API work or not:
http://static.ak.fbcdn.net/rsrc.php/v1/yz/r/VKS0m5QqjtF.js
Search for "function loadExternalJavascript" and you'll find this part
inside (line wrapped by me):
if(b){
d.onerror=d.onload=b;
d.onreadystatechange=function(){
if(this.readyState=="complete"||this.readyState=="loaded")b();
So b() (an argument passed to the method by the calling code) is going to
be called twice. Searching for onreadystatechange in that file shows it's
not the only place this is a potential problem.
* DOM Exceptions from popcornjs loading
Some source code is quoted in their bug report:
https://webmademovies.lighthouseapp.com/projects/63272-popcorn-js/tickets/375-domexception-in-opera-1101#ticket-375-5
All in all, this problem has bitten us many times on major sites, wasted
many hours of QA time on complex analysis, required site patches for
Hotmail and tripadvisor.com, and is still a potential compat problem with
Facebook code. I expect to keep running into issues caused by this until
we remove script.onreadystatechange support.
--
Hallvord R. M. Steen, Core Tester, Opera Software
http://www.opera.com http://my.opera.com/hallvors/