Last active
December 21, 2015 08:58
-
-
Save nessthehero/6281342 to your computer and use it in GitHub Desktop.
Boilerplate.js version 2
This file contains hidden or 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
// Do everything in a closure, so we don't affect or create any globals. | |
(function( $, window, document, undefined ) { | |
"use strict"; | |
var Project = Project || {}; | |
Project.init = function () { | |
}; | |
$(function () { | |
// Cached selectors | |
Project.$elm = {}; | |
// Arbitrary data (Comes after selectors so we can use them here) | |
Project.data = {}; | |
Project.init(); | |
}); | |
/** uncomment to see Namespace in the global scope for debugging. | |
window.Namespace = { | |
Project : Project; | |
}; | |
*/ | |
})( window.jQuery, window, window.document ); | |
/* | |
This way you leak nothing at all into the global namespace as it's all inside a closure. You import either jQuery or Zepto depending on what's supported in the page and even if jQuery is running in compatibility mode it won't break. | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment