Sitemap

Defer keyword in the javascript HTML script file

Jan 12, 2023
Press enter or click to view image in full size
Photo by Jackson Sophat on Unsplash

When I began working on JavaScript, I learned about the defer keyword used within the <script> tag. Whenever we generate an HTML file, we often see the defer keyword used in the JavaScript script tag, as shown below.

<script src = “app.js” defer></script>

basically, In HTML, the defer keyword is used in the script tag to specify that the JavaScript file should be executed only after the page has finished loading.

This can improve the performance of the page by allowing the browser to continue parsing the HTML while the JavaScript is being downloaded.

The defer keyword is only applicable to external scripts and is ignored if used on inline scripts.

Very basic, but we need to know everything available in the HTML script file

Happy learning :)

Shailesh Mishra
Shailesh Mishra

Written by Shailesh Mishra

Senior engineer. I write about backend architecture, distributed systems, mobile apps and AI-assisted development — lessons from real production systems.