<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script src="./test.js" defer></script>
  </head>
  <body>
    <script>
      // only document(html)
      window.addEventListener("DOMContentLoaded", () => {
        console.log("DOMContentLoaded!");
      });

      // after resources(css, images..)
      window.addEventListener("load", () => {
        console.log("load!");
      });
    </script>
  </body>
</html>
//test.js
console.log("JS Loaded!");

🚩JS Loaded! → DOMContentLoaded! → load!

✏

defer로 JS를 다운받으면, 자바스크립트 실행 후

HTML 문서 출력 후

나머지 resource 출력이 완료된다.