0

I would like to know the efficient way to dynamically load and unload Javascript plugins depending on options toggled on and off by the user.

Also, I was wondering if all the resources will really be freed if I simply remove the <script id="pluginId"> tag from the DOM ?

Thank you!

Cybrix
  • 3,248
  • 5
  • 42
  • 61

1 Answers1

-1

You can create a script tag and insert it into the DOM in the header:

 var head= document.getElementsByTagName('head')[0];
 var script= document.createElement('script');
 script.type= 'text/javascript';
 script.src= 'helper.js';
 head.appendChild(script);

Snippet from http://unixpapa.com/js/dyna.html

Brandon Frohbieter
  • 17,563
  • 3
  • 40
  • 62