Return to Snippet

Revision: 69931
at October 13, 2015 12:19 by Waltem


Updated Code
// IIFE - Immediately Invoked Function Expression
(function($, window, document) {

  // The $ is now locally scoped 

  // Listen for the jQuery ready event on the document
  $(function() {

  // The DOM is ready!

  });

  // The rest of the code goes here!

}(window.jQuery, window, document));
// The global jQuery object is passed as a parameter

//--------------------------------------------------

// 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() {

  // The DOM is ready!

  });

  console.log('The DOM may not be ready');

  // The rest of code goes here!

}));

Revision: 69930
at October 13, 2015 12:08 by Waltem


Initial Code
// IIFE - Immediately Invoked Function Expression
(function($, window, document) {

  // The $ is now locally scoped 

  // Listen for the jQuery ready event on the document
  $(function() {

  // The DOM is ready!

  });

  // The rest of the code goes here!

}(window.jQuery, window, document));
// The global jQuery object is passed as a parameter

Initial URL


Initial Description
IIFE - Immediately Invoked Function Expression. 
http://gregfranko.com/jquery-best-practices/#/7
http://gregfranko.com/jquery-best-practices/#/8

Initial Title
jQuery, how to start

Initial Tags
jquery

Initial Language
jQuery