title: What's the difference between Require.js and simply creating a <script> element in the DOM?
body: <p>What's the difference between using Require.JS amd simply creating a <code>&lt;script&gt;</code> element in the DOM?</p>
  
  <p>My understanding of Require.JS is that it offers the ability to load dependencies, but can this not simply be done by creating a <code>&lt;script&gt;</code> element that loads the necessary external JS file?</p>
  
  <p>For example, lets assume I have the function <code>doStuff()</code>, which requires the function <code>needMe()</code>. <code>doStuff()</code> is in the external file <code>do_stuff.js</code>, while <code>needMe()</code> is in the external file <code>need_me.js</code>.</p>
  
  <p><strong>Doing this the Require.JS way:</strong></p>
  
  <pre><code>define(['need_me'],function(){
      function doStuff(){
          //do some stuff
          needMe();
          //do some more stuff
      }
  });
  </code></pre>
  
  <p><strong>Doing this by simply creating a script element:</strong></p>
  
  <pre><code>function doStuff(){
      var scriptElement  = document.createElement('script');
      scriptElement.src = 'need_me.js';
      scriptElement.type = 'text/javascript';
      document.getElementsByTagName('head')[0].appendChild(scriptElement);
  
      //do some stuff
      needMe();
      //do some more stuff
  }
  </code></pre>
  
  <p>Both of these work. However, the second version doesn't require me to load all of the Require.js library. I don't really see any functional difference...</p>