Skip to content
Advertisement

Load one-script-after another

I have this simple function which loads scripts into the current DOM:

JavaScript

They are loaded fine and without no errors. I know there are event handlers when loading scripts programmatically:

  • onreadystatechange, and
  • onload, etc

Now I would like to wish to do the following:

  • Load first script from the array, and when the event handlers are COMPLETE load the next one, and so on (recursively).

Sorry, I have not provided the onreadystatechange and onload events in my function.

Advertisement

Answer

I would do this that way :

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement