http://requirejs.org/docs/start.html
The RequireJS downloadable module exists for use in a browser without using Node.js or Rhino.
To use it, download and save the script and include it in your page
<!DOCTYPE html> <html> <head> <title>My Sample Project</title> <script data-main="scripts/main" src="scripts/require.js"></script> </head> <body> <h1>My Sample Project</h1> </body> </html>
The data-main attribute will point to your main script, where you can load the rest of your scripts using:
require(["helper/util"], function(util) { //This function is called when scripts/helper/util.js is loaded. //If util.js calls define(), then this function is not fired until //util dependencies have loaded, and the util argument will hold //the module value for "helper/util". });
For more information, see http://requirejs.org .
source share