들어가며

— 브라우저는 한줄씩 읽으면서 분석하고 파싱한다.

— script tag에 async, defer 속성을 부여할 수 있다. (이 속성에 대한 default 값은 true이다.)

Untitled


<script>

script 태그가 무엇인지 먼저 정의해보자.

HTML 파일은 script 태그가 등잘할때까지 파싱한다. 그리고 script 태그를 만나면 HTML 파싱이 중단되고 즉시 스크립트를 다운로드 받고, 다운로드 스크립트가 실행된 후에 파싱이 재개된다.

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <title>Document</title>
		<script src="main.js">
  </head>
  <body>
  </body>
</html>

<script async>