title: Jquery loading up a script twice issue
body: <p>I have a function which loads up relevant js functions on click using ajax's shorthand <a href="http://api.jquery.com/jQuery.getScript/" rel="nofollow noreferrer">$.getScript()</a></p>
  
  <p>It looks like this:</p>
  
  <pre><code>$('#button').click(function() {
  
      $.getScript('/script.js');
  
      $.ajax({
          type: 'GET',
          url: '/file.php',
          cache: false,
          success: function(data) {
              $('#window').html(data);
          }
       });
  
  });
  </code></pre>
  
  <p>This works okay... until I click #button again and getScript loads script.js again meaning that any functions inside script.js get triggered not once, but twice.</p>
  
  <p><a href="https://stackoverflow.com/questions/2711443/questions-about-jquerys-getscript/2711453#2711453">In another thread somebody mentioned</a> this is a cacheing issue and that since $.getScript() is merely shorthand for $.ajax() <em>and</em> that <strong>by default ajax requests do not cache scripts</strong> that one should do the long version with 'cache: <em>true</em>'.</p>
  
  <p>So I tried:</p>
  
  <pre><code>$('#button').click(function() {
  
      $.ajax({
        url: 'script.js',
        dataType: 'script',
        cache: true,
        success: function(data) {
  
          $.ajax({
              type: 'GET',
              url: '/file.php',
              cache: false,
              success: function(data) {
                  $('#window').html(data);
              }
           });
  
        }
      });
  });
  </code></pre>
  
  <p>Unfortunately, I am still in the same boat and every time I click #button all my functions in script.js are being appended again and again.</p>
  
  <p>What is one to do? How do you go about loading a script just once, and/or checking to see if the resource is already loaded and if so, don't bother loading it all again?</p>