title: jQuery: How to insert or remove a .js file at runtime?
body: <p>i want to add a .js file after a link has been clicked.
  The .js file is a script, that has no function to call directly, but the file has to be inserted in the body part of the site.</p>
  
  <p>Another solution would be, if the file is called at page load and if the click event of the link is called, then remove the .js file.</p>
  
  <p>I've tried something like this, but nothing happens:</p>
  
  <pre><code>$(".myLink").click(function(){
      $.getScript("myJavascriptFile.js");
  });
  </code></pre>
  
  <p>and also here:</p>
  
  <pre><code>$(".myLink").click(function(){
  var script = document.createElement('script');
          script.type = 'text/javascript';
          script.src = "app_javascript/dragscroll.js";
          $(".myDiv").append(script); // or  $("body").append(script);
  });
  </code></pre>