开发者

What is the most efficient way to dynamically load and unload Javascript plugins?

开发者 https://www.devze.com 2023-02-13 01:04 出处:网络
I would like to know the efficient way to dynamically load and unload Javascript plugins depending开发者_开发百科

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

0

精彩评论

暂无评论...
验证码 换一张
取 消