且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如果一些脚本删除以前加载或包含的脚本,异步加载webapps会发生什么?

更新时间:2023-12-05 09:04:40

没有任何东西,< script> 节点从DOM中删除,但不能恢复在通过它们加载的JavaScript的执行过程中发生的事情。实际上,它们在实例化之后没有任何目的,这触发脚本下载和评估。

Nothing. The <script> nodes are removed from the DOM, but that cannot revert what happened during the execution of the JavaScript which was loaded through them. Actually, they do serve no purpose after they are instantiated, which triggers script downloading and evaluation.

可能受影响的唯一的事情是依赖DOM节点的其他脚本以存储,例如,从中读取模板字符串,内容位置网址或其他数据。

The only thing that might be affected are other scripts that rely on the DOM nodes to exist, for example to read templating strings, content location urls or other data from them.