Created
January 31, 2013 23:13
-
-
Save frontage/4687604 to your computer and use it in GitHub Desktop.
Simple starting point for requirejs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (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