JavaScript makes pages interactive. You add it to HTML with the script element.
Inline script
<p id="greeting">Hello.</p>
<script>
document.getElementById("greeting").textContent = "Hello from JavaScript.";
</script>
The script finds the element with the id greeting and changes its text.
External script
For anything bigger, put the code in a file and load it with src.
<script src="app.js"></script>
An external script file is cached by the browser and can be used on many pages. The script tag still needs a closing tag, even with src.
noscript
noscript shows content when JavaScript is turned off or fails to load.
<noscript>This feature needs JavaScript. Please turn it on.</noscript>
HTML first
Forgetting the closing tag
<script src="app.js" /> is not valid HTML. Write <script src="app.js"></script>.