Question

I'm working through loading javascript dependencies and I'm trying to answer a question about how getScript works.

I've built loading code that will automatically load scripts using getScript, basically by looping through an array of filepaths and calling getScript on each one.

Since getScript runs asynchronously, I had expected no guarantee which file would finish loading first and, presumably, begin executing in the main thread.

However, it appears that if I make multiple calls to getScript, the calls are queued internally, such that later files do not begin loading until the earlier files have completed. That is, my main function certainly runs asynchronously to getScript, but even if I load a very large file first (and a small file last), the large file always executes first.

Given that the order of execution never changes up (even when I load a very large file before a smaller one), I'm left to assume that while getScript executes asynchronously with the main execution thread, it does not execute asynchronously with itself...?

I hope that makes enough sense that someone can clarify this for me...

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top