异步脚本
html
<!DOCTYPE html>
<html>
<head>
<title>Example HTML Page</title>
<script type="text/javascript" async src="example1.js"></script>
<script type="text/javascript" async src="example2.js"></script>
</head>
<body>
<!-- 这里放内容 -->
</body>
</html>
指定async 属性的目的是不让页面等待两个脚本下载和执行,从而异步加载页面其他内容。
异步脚本一定会在页面的load 事件前执行,但可能会在DOMContentLoaded 事件触发之前或之 后执行。