title: How to add and remove js files dynamically
body: <p>I have a web page index.php, I want to add and remove JS files to this page dynamically</p>
  
  <p>So far I did,</p>
  
  <pre><code>&lt;script type="text/javascript" src="" id="dynamic_files"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>I had planned to change the src of this script tag by </p>
  
  <pre><code>function loadJsfiles( filename ){ 
      var filePath = 'include/js/'+filename;
      $("script#dynamic_files").attr('src',filePath);
  };
  </code></pre>
  
  <p>and the included js file has script tags in it:</p>
  
  <pre><code>document.write('&lt;script type="text/javascript" src="include/js/profile1.js"&gt;&lt;/script&gt;');
  document.write('&lt;script type="text/javascript" src="include/js/profile2.js"&gt;&lt;/script&gt;');
  document.write('&lt;script type="text/javascript" src="include/js/profile3.js"&gt;&lt;/script&gt;');
  document.write('&lt;script type="text/javascript" src="include/js/profile4.js"&gt;&lt;/script&gt;'); –
  </code></pre>
  
  <p>My question is that,</p>
  
  <p>will that script tag printed in to my document page, if so how do I remove it</p>
  
  <p>Reference: <a href="http://www.javascriptkit.com/javatutors/loadjavascriptcss2.shtml" rel="nofollow">Dynamic js files</a></p>