检查何时加载了异步javascript文件

时间:2015-12-03 21:11:05

标签: javascript html html5 asynchronous

我只想在加载所有异步文件后“引导”我的页面。有没有办法在加载异步文件时收到通知?

的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 个答案:

答案 0 :(得分:5)

为您的一个脚本提供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>