javascript - How does the browser know if a script is finished loading? -
how web browser know if script inside <script>
tag has finished loading?
the onload
event fires when resource (such script, or stylesheet) loaded:
var oscript = document.createelement("script"); oscript.type = "text\/javascript"; oscript.onload = function () { // when script loaded } document.getelementsbytagname("head")[0].appendchild(oscript); oscript.src = "path/to/script";
the onload
event not work on inline scripts.
Comments
Post a Comment