Nested JavaScript inclusions and IE

Consider the following scenario: file.html contains inline JS code to load remote.js and call a function in remote.js

And in remote.js

You would expect the output in this order and Firefox actually honors this order correctly:

  1. Before loading remote.js
  2. After loading remote.js
  3. In remote function

IE on the other hand will give you an error (“Object Expected”) and will call the function prematurely. Meaning that it executes before loading remote.js. This is an unexpected behavior. Fortunately, you can add the attribute defer=”defer”. This will specifically prevent IE from executing and actually produce proper result. Hmm, it’s IE! It has its own style!






Leave a Reply

Your email address will not be published. Required fields are marked *