I know that IE doesn't have a load
event for <script>
elements — is there any way to make up for that reliably?
I've seen some talk of things (e.g., requestState == "complete"
) but nothing very verifiable.
This is to be used so that code can be called after a script is finished loading, so that I don't have to use AJAX to load new sources (thus eliminating issues with cross-domain AJAX).
I want to add that if you don't support IE7 and below, you don't need
onreadystatechange
stuff. Source: quircksmode.orgSimplified and working code from original answer:
This is just an extension of ilia's answer. I used scriptTag like this: Works great:
You can use a script loader like head.js. It has its own load callback and it will decrease load time too.
From the
headjs
code: (slightly modified to be more portable)