Jump to content

IE - Multiple Javascript files loading out of order sometimes


Recommended Posts

I've got a decently large web app which works great in both Firefox and Chrome.

 

Note: All of the javascript files depend on JQuery.

 

Long story short: the index template file is loaded, filled with content, then output to the browser.  There are multiple javascript files to load at this point.  The include for the jquery file is in the header, and variably throughout the site other javascript files are included as needed.  With IE, sometimes some javascript files get loaded it seems before the actual jquery file, causing errors like 'Object expected' at line 1 char 1, therefore breaking all of the javascript on the page.  The only way around this is to keep refreshing the page until things load properly, at which point everything is fine.

 

Is there a trick to get IE to load javascript files in a specific order? Or what am I missing?

This might not be a loading problem, but an execution time problem. The browser might load the JS file and continue on the page and load the next file, but there might be a delay in executing the first file and the second file start executing which causes the error. This can happen specilly if you are loading locally or from cache.

 

To avoid this problem, make sure all your functions are in the ready function or add a defer="defer" to your additional script tags (after the jq).

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.