Jump to content

IE - Multiple Javascript files loading out of order sometimes


Stooney

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).

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.