Horje

How to add HTML <script> defer Attribute

It is a script that will be downloaded in parallel to parsing the page, and executed after the page has finished parsing.
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The script defer attribute</h1>

<script src="https://www.w3schools.com/tags/demo_defer.js" defer></script>

<p>The script above requests information from the paragraph below. Normally, this is not possible, because the script is executed before the paragraph exists.</p>

<p id="p1">Hello World!</p>

<p>However, the defer attribute specifies that the script should be executed later. This way the script can request information from the paragraph.</p>

</body>
</html>

Output should be:

How to add HTML <script> defer Attribute




Type:
html
Category:
Web Tutorial
Sub Category:
HTML Tag
Uploaded by:
Admin