Last active
August 29, 2015 14:15
-
-
Save jtwalters/1b86d6175be01d256d4c to your computer and use it in GitHub Desktop.
Some JS/jQuery patterns.
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
/** | |
* 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