Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

4
  • 1
    What if the script is still loading? How do you know if the file was not found or if you just have to wait? Commented Oct 14, 2013 at 3:28
  • This solution works in my testing, as long as the script tag is placed directly in the document source. The document's onload event doesn't fire until all resources referenced in the page source have already loaded (or failed). If you need to insert scripts into the DOM later, though, you need another approach. Commented Nov 27, 2013 at 18:29
  • Great solution. I don't understand why it hasn't been upvoted.
    – Lotfi
    Commented Nov 11, 2014 at 8:35
  • This assumes that the script will be loaded synchronously blocking everything else, which is not always true. In fact, it is not a recommended way of loading scripts.
    – Vitim.us
    Commented Jun 25, 2019 at 20:02