I see this code example in some unnamed provider documentation. It seems to load a script asynchronously and then call a function from it. I understand that checking if- undefined will prevent an explicit error, but is this not entirely wrong?
I believe that in IE8 / 9 it will work properly, but will be executed until the LOADER_URL script is loaded and executed; and I believe in many other browsers that support asynchronous attrbute, this will simply cause the inline block to execute code inside the if block only part of the time. The documentation states that tags are asynchronous and do not slow down the loading of your pages.
<script type="text/javascript" src="LOADER_URL" async="true"></script> <script type="text/javascript"> if (typeof (OBJECT_DEFINED_IN_LOADER_URL) != "undefined") { OBJECT_DEFINED_IN_LOADER_URL.Load(false); } </script>
Looking at an earlier version of her documentation, she had no proposal for an asynchronous attribute and this statement was not made. Did any technical writer make a mistake and say, βYes, that will work,β without proper testing in all browsers? In IE <= 9, it will work all the time. And since the asynchronous uber-fun code is for debugging ... maybe this worked for them ...
What is my suspicion :)
Jaimie sirovich
source share