angular-load icon indicating copy to clipboard operation
angular-load copied to clipboard

Re-load or unload script?

Open maeishoj opened this issue 10 years ago • 4 comments

Hi, I am in a situation where I need to either force a reload of a script, or unload and load it again.

Is there a way to add this?

maeishoj avatar May 27 '15 07:05 maeishoj

same here i want!

vaneshmali avatar Jul 14 '15 08:07 vaneshmali

Same here, any idea?

ganmedia avatar May 29 '16 22:05 ganmedia

I've been using this solution to do this: http://stackoverflow.com/a/9425964

soumak77 avatar Jun 20 '16 05:06 soumak77

There seems to be an intermittent issue with attempting to unload the file after loading it through angularLoad. As long as there is a significant amount of time between unloading/loading, things work as expected. However, when attempting to load/unload files quickly, angularLoad can get into a scenario where the file reference is still in the promise cache (i.e. promises[url] is defined), but isn't loaded in the DOM. This causes angularLoad to skip creation of the element and therefore the file is not reloaded as expected.

In order to resolve this issue, angularLoad would have to be aware of when the element it created is removed from the DOM. There don't appear to be any cross-browser solutions for knowing when an element is removed from the DOM, so it doesn't seem possible for angularLoad to know this automatically. As a result, a new method would have to be added to inform angularLoad that the script it loaded previous has been unloaded.

It would seem strange to expose a new method for angularLoad that simply notifies it when a script has been unloaded. Unloading of the script should really be the job of the angularLoad module itself. I'll look into creating a PR with exposes an unloadScript and unloadCSS methods, using the solution provided in the link above.

@urish would you be open to using this solution or do you have suggestions on other solutions to unload css and js files?

soumak77 avatar Jul 07 '16 00:07 soumak77