defer attribute is used to specify the script file must be load after parsing the page content
The alert box will be display the value of the element which has id as “p1”.
Output for defer Attribute in HTML:
The content is written inside the <p> tag as it is shown in the output.
alert dialog box shows “Wikitechy”. If we did not declare the defer attribute the value cannot be displayed in the alert box, because the script file declared before the content.
Browser Support for defer Attribute in HTML:
yes
10.0
3.6
Yes
15.0
Tips and Notes
The defer attribute is only used in external <script> element.