title: Load js script only when it has not been loaded already and then only once
body: <p>I've been trying to load a big js script only once. I'm not loading it on page load as it is not needed then and will slow the page load down.</p>
  
  <p>So I've been trying to load it with jQuery's $.getScript and Modernizr.load ( since I'm already using Modernizr ).</p>
  
  <p>I've tried iterating through all the <code>&lt;script&gt;&lt;/script&gt;</code> elements and checking their src attributes and seeing if this script is one of them, but that still loaded them each time I ran the test.</p>
  
  <p>I also tried setting a global variable to true at the beginning of the script and checking if that was set and it still loaded every time I checked.
  Here is what I was doing in that instance:</p>
  
  <pre><code>Modernizr.load({
      test:if(window.flag === undefined),
      yep:'conversation.js',
      callback:function(){    
          antecedent();   
      }
  });
  </code></pre>
  
  <p>and <code>var flag = true;</code> was set at the first line of conversation.js</p>
  
  <p>Does anyone have any ideas how I can get this script to load once when this test is called to check if it is has been loaded and only load it once then?</p>
  
  <p>** Edit/Update: ** <code>document.getElementsByTagName('head')[0].appendChild(document.createElement('sc‌​ript')).src = 'conversation.js';</code> could work, but how do I check if the script is already loaded or not and then only call this if it isn't already included?</p>