I have an abstract script, any-script.js
. It is included it into the html, or it is loading if it is needed. I have some code which calls some some other code, which calls function from loaded script. How can I check this script to know if it loaded 100% and executed? I don't know what code will be called, it is just some abstract callback.
If I load this script dynamically, all goes fine, I can add an event lister and to wait until it fires script.addEventLister("load")
. But if my script is already in DOM with async attribute, and if it is loaded, I can't just add some evet listener, because it will not fire. At other side I can't to be sure, that the script was loaded. Because script tag in dom !== script is loaded
.
script.addEventLister("load")
- is working only if you 100% know, that the script is not loadedscript tag in dom !== script is loaded
May be exists some browser api to correctly check this?