Skip to content

Instantly share code, notes, and snippets.

@davidchase
Created July 17, 2013 00:33
Show Gist options
  • Save davidchase/6016591 to your computer and use it in GitHub Desktop.
Save davidchase/6016591 to your computer and use it in GitHub Desktop.
// IIFE - Immediately Invoked Function Expression
(function(yourcode) {
// The global jQuery object is passed as a parameter
yourcode(window.jQuery, window, document);
}(function($, window, document) {
// The $ is now locally scoped
// Listen for the jQuery ready event on the document
$(function() {
console.log('The DOM is ready');
// The DOM is ready!
});
console.log('The DOM may not be ready');
// The rest of code goes here!
}));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment