1. 在html中使用javascript需使用<script>标签;引入外部js使用src指向文件url;
<pre name="code" class="javascript" style="font-size: 18px;"><script type="text.javascript" defer="defer" src="example,js"></script>
2.在不使用defer和async属性的情况下,js会按<script>标签在页面中出现的顺序依次被解析
3.使用defer属性可以使js在html文档完全呈现之后再执行(仅适用于外部js)
<script type="text.javascript" defer="defer" src="example,js"></script>
同样仅适用于外部js
<script type="text.javascript" async src="example,js"></script>