script element
The HTML element that loads or contains JavaScript for the page.
In more detail
A plain script tag without defer, async or type="module" is parser-blocking: the HTML parser stops until the script has downloaded and run, because the script might change the document. Adding defer or async lets the download happen in the background.
Related terms
- defer attribute — A script attribute that downloads the script in the background and runs it, in document order, only after the HTML has finished parsing.
- async attribute — A script attribute that downloads the script in the background and runs it as soon as it arrives, without waiting for parsing to finish or for other scripts.
- ES module — A JavaScript file that uses import and export to share code with other files, loaded in the browser with <script type="module">.
- inline script — JavaScript written directly inside a script tag or an event attribute such as onclick, rather than loaded from a file.
Taught in
- CSS Parsing, The CSSOM And The Render Tree — Frontend Architecture & Web Platform
- Critical Rendering Path: Preload, Prefetch And Scripts — Frontend Architecture & Web Platform
- Content Security Policy (CSP), Trusted Types And XSS Defenses — Frontend Architecture & Web Platform
- CSRF Mitigations, SameSite Cookies And Subresource Integrity — Frontend Architecture & Web Platform