title: Requirejs domReady plugin vs Jquery $(document).ready()?
body: <p>I am using RequireJS and need to initialize something on DOM ready. Now, RequireJS provides the <a href="http://requirejs.org/docs/api.html#pageload"><code>domReady</code> plugin</a>, but we already have jQuery's <code>$(document).ready()</code>, which is available to me since I have required jQuery.</p>
  
  <p>So I have got two options:</p>
  
  <ol>
  <li><p>Use the <code>domReady</code> plugin:</p>
  
  <pre><code>require(['domReady'], function (domReady) {
      domReady(function () {
          // Do my stuff here...
      });
  });
  </code></pre></li>
  <li><p>Use <code>$(document).ready()</code>:</p>
  
  <pre><code>$(document).ready(function() {
      // Do my stuff here...
  });
  </code></pre></li>
  </ol>
  
  <p><strong>Which one should I choose, and why?</strong></p>
  
  <p>Both the options seems to work as expected. I am not confident in the jQuery's one because RequireJS is doing its magic; that is, since RequireJS will dynamically add scripts, I'm worried that DOM ready may occur before all of the dynamically-requested scripts are loaded. Whereas, RequireJS will add a burden on additional JS just for <code>domReady</code> when I already have jQuery required.</p>
  
  <h2>Questions</h2>
  
  <ul>
  <li>Why does RequireJS provide a <code>domReady</code> plugin when we can have jQuery's <code>$(document).ready();</code>? I don't see any advantage of including another dependency.</li>
  <li>If its just to feed a need, then why not provide one for cross-browser AJAX?</li>
  </ul>
  
  <p>As far as I know, a module that requires <code>domReady</code> won't be fetched or executed after the document is ready, and you could do the same requiring jQuery as well:</p>
  
  <pre><code>require(['jQuery'], function ($) {
      $(document).ready(function () {
          // Do my stuff here...
      });
  });
  </code></pre>
  
  <p>To be more clear on my question: <strong>what's the difference between requiring <code>domReady</code> or <code>jQuery</code>?</strong></p>