remove javascript file from a page header

Asked

Viewed 156 times

1

I have an Asp.net application where I load, according to the will of the user several usercontrols.

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

How can I remove these references to files not needed anymore?

1 answer

1

You can add in your script those that are important and overwrite the page head by placing these important and deleting the unnecessary ones, 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;

Browser other questions tagged

You are not signed in. Login or sign up in order to post.