The Script Tag
The <script> tag embeds or links JavaScript in HTML. Without any attributes it blocks HTML parsing while the script downloads and runs.
Placing scripts at the end of <body> ensures the DOM is available before the script runs.
The <script> tag embeds or links JavaScript in HTML. Without any attributes it blocks HTML parsing while the script downloads and runs.
Placing scripts at the end of <body> ensures the DOM is available before the script runs.
<!-- Inline script -->
<script>
console.log("Page loaded");
</script>
<!-- External script at end of body -->
<body>
<h1>Hello</h1>
<script src="app.js"></script>
</body>
Place scripts at the bottom of <body> or use defer to avoid blocking page rendering.