title: jQuery best practices in case of $('document').ready
body: <p>I was researching on jQuery best practices and found <a href="http://gregfranko.com/jquery-best-practices/#/5" rel="noreferrer">this</a> article <a href="https://stackoverflow.com/users/1172750/greg-franko">by Greg Franko</a> </p>
  
  <p>Normally, I do:</p>
  
  <pre><code>$("document").ready(function() {
      // The DOM is ready!
      // The rest of the code goes here
  });
  </code></pre>
  
  <p>But the article recommends to use:</p>
  
  <pre><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
  </code></pre>
  
  <p>I can see the comments there, but I couldn't figure out what it exactly saying.</p>
  
  <p>So, which is the better approach and why?</p>
  
  <p>I know that both methods will work, but how does the second one become the <em>better</em>? </p>