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

后端 未结 2 587
栀梦
栀梦 2021-01-23 17:23

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

Let have several scripts included:

相关标签:
2条回答
  • 2021-01-23 17:25

    The only thing that happens is that the source code in the scripts goes away.

    The scripts have already been parsed and executed, which creates Javascript objects (e.g. function objects), and those objects doesn't go away when you remove the source code.

    0 讨论(0)
  • 2021-01-23 17:37

    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.

    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.

    0 讨论(0)
提交回复
热议问题