RequireJs is a very helpful JavaScript Module Loader. If you’ve been working on BackboneJS, AngularJs or KnockoutJs you would have most likely come across RequireJs. Also it is very likely that while working with RequireJs you would have come across the Error : Load timeout for modules message.

The possible causes for this error could be that :

  1. The path to a JavaScript file was wrong or the file is missing from the server and as a result RequireJs encountered a 404 while requesting for the JavaScript file.
  2. There was a script error in one of the modules or JavaScript files. Usually this type of error would also be visible in the console panel of the browser.
  3. A timeout occured while requesting for the JavaScript modules or file due to slow server or other reasons. The timeout can also occur when two module IDs are set to the same file.

However, if after the initial analysis you realize that the Error was due to Timeout, then you may try to reset the timeout value in RequireJs config. By default a timeout of 7 seconds is set in RequireJs. You can reset this value to a different value too. The RequireJs config has an option named waitSeconds which as mentioned defaults to 7 seconds. So now, if the modules don’t load in the specified timeout, RequireJs would stop loading the module and throw the timeout error. To get rid of this, you may reset the waitSeconds to 0 (Zero). On doing so RequireJs would wait for infinite till the JavaScript loads. However, I suggest that you use this config value with a caution. After setting the waitSeconds to 0 your code might look similar to the following :

This setting would reset the timeout time to infinite. You may also try increasing the timeout time instead of resetting it to 0 . Hope this fix works for you.

Related Posts

  • How to Minify a Javascript File? The web technology today has improved dramatically and the way scripting is done on websites have changed drastically over the years now. Gone are the days when […]
  • What is a constructor in Javascript ? If you have been working on or learning Object Oriented JavaScript, you must have come across the word "constructor" a number of times. A constructor is basically a […]
  • How to search for a string in JavaScript? The String data type must be the most common data type that we use in JavaScript. One of the most common functionality around string that we would have come across is […]
  • How to join or merge an Array in JavaScript? I'm sure you must have had a scenario where you had to join or merge two different Arrays. Well, let me tell you that its an easy task. JavaScript has a native method […]
  • How to make placeholder work in IE ? One of the interesting features of HTML5 is the "placeholder" attribute. This new attribute has helped web developers save a lot of time as without it we would have had […]
  • How to set a timer in JavaScript? Quite often you might come across scenarios wherein you would need to have a timer set in JavaScript. For instance, you might want to call a function after a delay of […]