How to unload a javascript from an html?

前端 未结 7 2102
予麋鹿
予麋鹿 2020-11-28 10:27

How can I unload a JavaScript resource with all its defined objects from the DOM?

Im developing a simple framework that enables to load html fragments into a \"main\

7条回答
  •  情歌与酒
    2020-11-28 11:11

    This cannot be done.

    When a script is executed, function definitions are added to the global window object. There may be debugging symbols attached to the function that indicate where the function came from, but this information is not available to scripts.

    About the only way you could achieve something like this would be to create a pseudo-namespace in the script and then throw away that whole namespace when you are done with it. However, this question hints to me that you are trying to do something the wrong way. Perhaps elaborating on your scenario would help us provide alternate solutions.

提交回复
热议问题