Skip to content

Instantly share code, notes, and snippets.

@jtwalters
Last active August 29, 2015 14:15
Show Gist options
  • Save jtwalters/1b86d6175be01d256d4c to your computer and use it in GitHub Desktop.
Save jtwalters/1b86d6175be01d256d4c to your computer and use it in GitHub Desktop.
Some JS/jQuery patterns.
/**
* JS Patterns
*/
/**
* 1. Mixed jQuery
*/
(function($, window, document, undefined) {
var foo,
bar;
// Some other code
// DOMReady
$(document).ready(function () {
});
})(jQuery, window, document);
/**
* 2. Pure jQuery ready
*/
jQuery(function namespaceReady($) {
});
/**
* 3. Module
*/
var Module = Module || {};
Module.submodule = {
ready: function submoduleReady($) {
},
foo: function foo() {
},
bar: function bar() {
}
};
jQuery(Module.submodule.ready);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment