Ask any question about Web Development here... and get an instant response.
What html technique helps prevent blocking resources during initial page load?
Asked on Oct 20, 2025
Answer
To prevent blocking resources during the initial page load, you can use the "defer" attribute on your script tags. This attribute tells the browser to continue parsing the HTML document while the script is being fetched, and only execute the script after the document has been fully parsed. This technique is particularly useful in optimizing the loading performance of your web pages.
<!-- BEGIN COPY / PASTE -->
<script src="your-script.js" defer></script>
<!-- END COPY / PASTE -->Additional Comment:
- The "defer" attribute is only effective for external scripts, not inline scripts.
- Scripts with "defer" maintain their order of execution as they appear in the document.
- Using "async" is another option, but it executes scripts as soon as they are loaded, which may not preserve execution order.
- Consider using "defer" for scripts that rely on the DOM being fully constructed.
Recommended Links:
