如果一些脚本删除以前加载或包含的脚本,异步加载webapps会发生什么? [英] what happens in asynchronous loading of webapps if some script delete the previously loaded or included scripts?

查看:158
本文介绍了如果一些脚本删除以前加载或包含的脚本,异步加载webapps会发生什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

the question is: what happens in asynchronous loading of webapps if some script delete the previously loaded or included scripts?

<script src="Squel.js" async="" type="text/javascript"></script>
<script src="PSquel.js" async="" type="text/javascript"></script>
<script src="MySquel.js" async="" type="text/javascript"></script>



无论是通过标记包含还是通过requireJS动态包含,异步脚本的顺序都相同发生。

No matter, whether it is included by markup or dynamically via requireJS, the same order of asynchronous script includes happen.

MySquel.js文件的内容可能是以下恶意代码:

Content of MySquel.js file could be this malicious code:

document.getElementsByTagName('script').forEach(function(val,i,arr){
if(/PSquel/.test(val.src)){
val.parentNode.removeChild(val);
}
}

我感兴趣的是,有任何奇怪的是,在任何特定的浏览器中打开内存空洞
我也对任何边缘情况感兴趣,你知道!

Of course the question is very browser specific though, i'm interested in that is there any quirks around that opens up memory holes in any specific browser. I am also interested about any edge cases you know!

我非常感谢您在任何关于可能不安全的脚本加载的边缘情况下的响应。
感谢。

I am very thankful about your response in any of the edge cases you know concerning possibly unsecure script loads! Thanks.

推荐答案

没有任何东西,< 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.

这篇关于如果一些脚本删除以前加载或包含的脚本,异步加载webapps会发生什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆