How to delete script loaded by .getScript()

久未见 提交于 2019-12-04 06:14:37

getScript doesn't "load" a script in the sense of keeping it around; it downloads the script from the server and runs it immediately. So there's no need to remove it.

However, any DOM objects that the script creates, or functions it defines, etc., will continue to exist. Removing these will require knowing specifically what they are; probably your best bet is to have your script define a function that deletes all of the things that the rest of the script creates.

Unfortunately once the code has been executed you can't unexecute it.

However, if file.js creates DOM objects, you can delete those via delete object.name, and if you're bind()ing events you can always unbind() them.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!