Skip to content

Instantly share code, notes, and snippets.

@frontage
Created January 31, 2013 23:13
Show Gist options
  • Select an option

  • Save frontage/4687604 to your computer and use it in GitHub Desktop.

Select an option

Save frontage/4687604 to your computer and use it in GitHub Desktop.
Simple starting point for requirejs
(function(){
//put this in your index, this should be the only script file you load
//data-main points to the config file
//<script data-main="app/config" src="app/libs/require.js"></script>
require.config({
//deps is used if you abstract your require([])
//deps: ['main'],
paths: {
jquery: "libs/jquery",
underscore: "libs/underscore",
backbone: "libs/backbone",
use: "plugins/use"
},
use: {
backbone: {
deps: ["use!underscore", "jquery"],
attach: "Backbone"
},
underscore: {
attach: "_"
}
}
});
require([
//require scripts here
'app'
],function(){
//scripts are avaliable here
//remember to wrap a define() around your scripts to idendify their dependicies
//define(['use!backbone'],function(){
//backbone dependant code here
//});
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment