JAVASCRIPT
드림코딩 자바스크립트 첫번째
Made Project
2020. 7. 7. 14:07
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script asyc src="main.js"></script>
</head>
<body>
</body>
</html>
asyc는 블린형이고 htm이 실행하다가 main.js 다운로드가 완료되면 파싱을 멈추고 자바스트립트를
실행하고 다시 나머지 html을 실행합니다.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script defer src="main.js"></script>
</head>
<body>
</body>
</html>
defer은 자바스크립트를 다운로드를 시키고 html이 다 실행되고 다시 자바스크립트를 실행된다.
defer은 순서대로 실행되기 때문에 더 확실하다.
참고
순수 자바스크립트를 할때
"use strict"
console.log("hellow world");
"use strict"를 선언하면
자바스크립트 엔진이 효율적으로 사용되게 된다.