w3resource

HTML defer attribute

defer

The purpose of the HTML defer attribute is to tell the user agent to defer the execution of a script.

Most of the modern browsers don't support this attribute.

Supported elements

HTML defer attribute supports script element.

Syntax

<script type="script_type" defer >.....</script>

Type of value

defer.

Value

NA.

Default value

There is no default value of HTML defer attribute.

Supported doctypes

HTML 4.01 strict, HTML 4.01 transitional, HTML 4.01 frameset.

Example of HTML defer attribute with script

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Example of HTML defer attribute with script</title>
<script type="text/javascript" defer>
function w3r (){
document.write("this is an example of defer attribute")
} 

</script>
</head>
<body onload="w3r()" >
<p>This is an example of HTML defer attribute. </p> 
</body>
</html>

Result

html defer attribute with script

View this example in a separate browser window

Example of HTML defer attribute with script.

Previous: HTML declare attribute
Next: HTML dir attribute

Test your Programming skills with w3resource's quiz.



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://www.w3resource.com/html/attributes/html-defer-attribute.php