src
External JavaScript file to load.
Learn src, type, defer, async, nomodule, integrity, crossorigin as part of the HTML attribute system: what they configure, where they belong and which mistakes to avoid.
Scripts
The script element can block rendering, defer execution, load modules, check integrity and support cross-origin resources. Its attributes affect performance and reliability.
Many frontend bugs begin with script loading order. Knowing defer, async and type="module" prevents a lot of guessing.
src, type, defer, async, nomodule, integrity, crossorigin. Attributes that control JavaScript loading, modules and security checks. What belongs here
srcExternal JavaScript file to load.
deferDownloads during parsing and runs after the document is parsed.
asyncDownloads during parsing and runs as soon as ready.
type="module"Loads the script as a JavaScript module.
nomoduleFallback for older browsers that do not support modules.
integrity + crossoriginSubresource integrity and cross-origin loading checks.
Syntax in context
Use defer for many normal scripts. Use async for independent scripts such as analytics. Use modules for modern app code.
<script defer src="assets/js/navigation.js"></script> <script type="module" src="assets/js/app.js"></script>
Good versus weak
<script defer src="assets/js/navigation.js"></script> <script type="module" src="assets/js/app.js"></script>
<script src="big-app.js"></script> <script async src="depends-on-dom.js"></script>
Rules that matter
Deferred scripts run after parsing, which avoids many missing-element bugs.
Async scripts can execute in unpredictable order.
Modules are deferred by default and support imports.
External scripts can affect security and performance.
A script tag should make it obvious whether order, DOM readiness or independent loading matters.
Production thinking
Attributes are small, but they change how an element works. A good attribute can make a link usable, an image understandable, a form easier to complete or a script safer to load.
If JavaScript fails, important content should still be reachable or a noscript fallback should explain the requirement.
Script attributes affect load speed, execution order, caching, security and how safely third-party code enters the page.
Live code lab
Edit the HTML or CSS, then use Run to refresh the preview. The preview is isolated, so links and forms stay inside this practice area.
Mini assignment
Practice assignment
Try it yourself
Self-check
Do not only read this page. Answer these questions out loud or write the answers in your own notes. If one answer feels vague, revisit the examples before moving on.