What is the most efficient way to dynamically load and unload Javascript plugins?
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!
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
精彩评论