Skip to content

Instantly share code, notes, and snippets.

@jboesch
Created October 22, 2010 22:35
Show Gist options
  • Save jboesch/641505 to your computer and use it in GitHub Desktop.
Save jboesch/641505 to your computer and use it in GitHub Desktop.
requireJS dependencies
// Using http://requirejs.org/
// loading scripts/misc/person.js
require(["misc/person"], function(person) {
person.loaded(function(){
alert('dependencies loaded!');
// dependencies loaded, now do something with person
});
});
// Inside scripts/misc/person.js
define(function(){
var dependencies = [
'helper/ear', // looking to scripts/helper/ear.js
'helper/nose',
'helper/eyes'
];
return {
loaded: function(cb){
require(dependencies, function(){
cb.apply(this, arguments);
});
}
}
});
@SlexAxton
Copy link

oh, good to know. Doesn't it take a string as the first argument, or are you using the file location to define the module name?

@jboesch
Copy link
Author

jboesch commented Oct 22, 2010

Yeah I'm just using the file location as the module name. I figured I'd just save some chars

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