http://mojo.codehaus.org/js-import-plugin/
{
"jquery": {
"src": "file://Users/michael/scripts/vendor/jquery/1.7.0/jquery.js"
},
"underscore": {
"src": "file://Users/michael/scripts/vendor/underscore/1.2.1/underscore.js",
| function main() { | |
| var count = 0; | |
| } | |
| console.log(count); // undefined |
| MyApp = 42; | |
| (function() { | |
| if (typeof MyApp === 'undefined') { | |
| var MyApp = { oops: true }; | |
| } | |
| console.log(MyApp); | |
| }()); |
| Traffic analysis of your site shows that most visitors | |
| require module A (big, almost never changes) and only | |
| a few visitors require module B (small, changes often). | |
| Keep those modules at separate URLs and everyone will | |
| only download module A rarely. On subsequent pages/visits | |
| that data will come straight from user-agent's cache. | |
| Combine them into a single URL and everyone will have | |
| to download modules A+B every single time module B |
| /* | |
| * File: jquery.dataTables.js | |
| * Version: 1.9.0.dev | |
| * Description: Paginate, search and sort HTML tables | |
| * Author: Allan Jardine (www.sprymedia.co.uk) | |
| * Created: 28/3/2008 | |
| * Language: Javascript | |
| * License: GPL v2 or BSD 3 point style | |
| * Project: Mtaala | |
| * Contact: allan.jardine@sprymedia.co.uk |
| /** | |
| * Classic Atari PONG! | |
| * @author Rob Taylor <manix84@gmail.com> | |
| * @date 15/11/2011 | |
| */ | |
| define([ | |
| 'jquery-1' | |
| ], function ($) { | |
| var Pong = function () { |
| function findMyOwnTag(mySrc) { | |
| var scripts = document.getElementsByTagName('script'); | |
| for (var i = scripts.length-1; i >= 0; i--) { | |
| if (scripts[i].src && scripts[i].src.indexOf(mySrc) > -1) { | |
| return scripts[i] | |
| } | |
| } | |
| } | |
| myScriptNode = findMyOwnTag('bloader.js'); |
| <script> | |
| bloader = { | |
| baseUrl: '/path/to/my/js', | |
| pluginPath: 'for/some/reason/plugins/r/here', | |
| paths: { | |
| curl: 'curl/src/curl', | |
| cssx: 'cssx/src/cssx', | |
| my: '../../my-lib/' | |
| }, | |
| apiName: 'someOtherName' |
http://mojo.codehaus.org/js-import-plugin/
{
"jquery": {
"src": "file://Users/michael/scripts/vendor/jquery/1.7.0/jquery.js"
},
"underscore": {
"src": "file://Users/michael/scripts/vendor/underscore/1.2.1/underscore.js",
| // Be explicit - provide names for everything. | |
| (function(window) { | |
| /** | |
| * The ToolBox | |
| * | |
| * @class ToolBox | |
| */ | |
| var ToolBox = {}; | |
| /** |
| /** | |
| * Attaches the script represented by the URL to the current | |
| * environment. Right now only supports browser loading, | |
| * but can be redefined in other environments to do the right thing. | |
| * @param {String} url the url of the script to attach. | |
| * @param {String} contextName the name of the context that wants the script. | |
| * @param {moduleName} the name of the module that is associated with the script. | |
| * @param {Function} [callback] optional callback, defaults to require.onScriptLoad | |
| * @param {String} [type] optional type, defaults to text/javascript | |
| */ |