remove javascript file from header of a page

1

I have an asp.net application where I load, according to user's desire various usercontrols.

Each usercontrol loaded, via scriptmanagerproxy loads a javascript file. As it is loaded by the usercontrol, it will stop at the Header of the page. The problem is that as they are not removed along with the usercontrol, over time they accumulate.

How can I remove these references to javascripts files that are no longer needed?

    
asked by anonymous 18.09.2014 / 16:02

1 answer

1

You can add in your script those that are important and overwrite the head of the page by putting these important ones and deleting those not necessary, for example:

var scriptsNecessarios = [];
scriptsNecessarios[0] = "<script src=\"jquery-1.8.0.min.js\"></script>";
scriptsNecessarios[1] = "<script src=\"bootstrap.min.js\"></script>";
var head = scriptsNecessarios.toString();
head = scriptsNecessarios.replaceAll(',',' <br/> ');
document.head.innerHTML = head;
    
18.09.2014 / 16:52