Skip to content

Instantly share code, notes, and snippets.

@jonnyreeves
Created June 12, 2012 14:25
Show Gist options
  • Save jonnyreeves/2917860 to your computer and use it in GitHub Desktop.
Save jonnyreeves/2917860 to your computer and use it in GitHub Desktop.
RequireJS Loading order
// This doesn't appear to be the case...
define(function (require) {
// Is there any guarantee that `moduleA` is loaded first?
var loadMeFirst = require('moduleA');
var loadMeSecond = require('moduleB');
});
// In this case `moduleA` *appears* to always be loaded before `moduleB`
define([ 'moduleA', 'moduleB' ], function (loadMeFirst, loadMeSecond) {
});
@jrburke
Copy link

jrburke commented Jun 12, 2012

If you are using requirejs 2.0, the shim config is helpful for this kind of situation where you have implicit dependencies (the library does not call define()) but want to use it as a module:

http://requirejs.org/docs/api.html#config-shim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment