Last active
December 24, 2015 23:09
-
-
Save deleteme/6877877 to your computer and use it in GitHub Desktop.
This file contains 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
// define ds, which adds to a queue | |
// must be included in <head>, before anything else. | |
function ds(){ | |
(ds.q = ds.q || []).push(arguments); | |
return ds; | |
} | |
// process queue, included at the end of vendored js | |
function run(args){ | |
var module = args[0](); | |
return ds[module.name] = module; | |
} | |
while (ds.q.length) { | |
run(ds.q.pop()); | |
} | |
// redefine push to run the module async as soon as possible | |
ds.q.push = _.partial(_.defer, run); | |
// Example of page specific module | |
ds(function(){ | |
var pub = { name: 'stuff' }; | |
function doStuff(){} | |
$(function(){ | |
$('.stuff').on('click', doStuff); | |
}); | |
return pub; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment