4

I'd like to "bootstrap" my page only after all async files have been loaded. Is there a way I can be notified when an async file has been loaded?

index.html

<script src="fileone.js" type="text/javascript" async></script>
<script src="filetwo.js" type="text/javascript" async></script>
<script src="bootstrap.js" type="text/javascript" async></script>
1
  • Why don't you load them using javascript ? Appending this using JS allow you to use any event you wish Commented Dec 3, 2015 at 21:16

1 Answer 1

10

Giving one of your scripts an ID...

<script src='fileone.js' type='text/javascript' async id='script_1'></script>
<script>
    document.getElementById("script1").onload = script.onreadystatechange = function(){ alert("Script loaded!"); }
</script>
Sign up to request clarification or add additional context in comments.

2 Comments

How does monitoring one script assure the others are loaded as well?
You would do one of those "document.getElementById()" lines for each script, replacing the "script1" with the other script ID.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.