-2

If I dynamically insert a script tag, from within a <script> in <head>, will the download/loading of that new script cause the full page to block until that new script is ready?

Deal
  • 106
  • 10
  • 1
    Possible duplicate of [Script Tag - async & defer](https://stackoverflow.com/questions/10808109/script-tag-async-defer) – mpm Sep 13 '18 at 18:34
  • How is this a duplicate? I'm asking about dynamic scripts while the page is loading and getting parsed, not about the different ways to specify a script load/download requirement. Are you implying that async/defer can be used to delay dynamic script loading? – Deal Sep 13 '18 at 19:05

1 Answers1

0

Loading of that new script file will not block your page, but indeed if that new loaded script execution might can cause it block, since it could take time to execute that newly loaded script. Hope this answers your question.

  • So you mean executing the code to dynamically inject a script will block a script. That's fine, I understand. But the new script being loaded/executed, that does not? – Deal Sep 13 '18 at 19:06
  • I meant there there are several events happening, which are loading, another is loaded and possible next one is executing loaded javascript, so loading will not be a problem, but indeed when newly loaded file executes it code then it might can create some problems like if there is a loop and its taking so much to execute, then this could happen, and there are several reasons because of this could happen. Hope I have clarified my answer. – Poojan Bedi Oct 06 '18 at 00:47