{"id":9359,"date":"2022-10-06T05:06:43","date_gmt":"2022-10-06T05:06:43","guid":{"rendered":"https:\/\/mdr.foobrdigital.com\/?p=9359"},"modified":"2022-10-06T05:06:43","modified_gmt":"2022-10-06T05:06:43","slug":"html-defer-attribute","status":"publish","type":"post","link":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/2022\/10\/06\/html-defer-attribute\/","title":{"rendered":"HTML defer Attribute"},"content":{"rendered":"\n<p>The HTML&nbsp;defer&nbsp;attribute specifies that a script is executed when a page has finished the parsing. It is a boolean attribute. This attribute works for external scripts and must be used only when the&nbsp;src&nbsp;attribute is present.<\/p>\n\n\n\n<p>There isn\u2019t any difference between HTML 4.01 and\u00a0HTML5. In\u00a0XHTML, the\u00a0defer\u00a0attribute must be specified as\u00a0&lt;script defer=\u201ddefer\u201d>\u00a0as attribute minimization is forbidden.<\/p>\n\n\n\n<p>You can use this attribute on the\u00a0&lt;script>\u00a0element.<\/p>\n\n\n\n<p>An external script can be executed in the following ways:<\/p>\n\n\n\n<ul><li>When\u00a0async\u00a0is present, the script will be executed asynchronously while the page continues the parsing.<\/li><li>When\u00a0async\u00a0is not present but\u00a0defer\u00a0is present, the script will be executed when the page finishes the parsing.<\/li><li>When neither\u00a0async\u00a0or\u00a0defer\u00a0is present, the script will be executed immediately before the browser continues the parsing.<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"syntax-2\">Syntax<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;script src=\"example.js\" defer&gt;&lt;\/script&gt;<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"example-of-the-html-span-class-attribute-defer-span-attribute-4\">Example of the HTML&nbsp;defer&nbsp;attribute:<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n  &lt;head&gt;\n    &lt;title&gt;Title of the documnet&lt;\/title&gt;\n    &lt;script src=\"example.js\" defer&gt;&lt;\/script&gt;\n    &lt;noscript&gt;Sorry, your browser doesn't support JavaScript!&lt;\/noscript&gt;\n  &lt;\/head&gt;\n  &lt;body&gt;\n    &lt;h1&gt;Example&lt;\/h1&gt;\n    &lt;p&gt;The \"defer\" attribute  specifies that a script is executed when a page has finished the parsing. It is a boolean attribute.&lt;\/p&gt;\n  &lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>The HTML&nbsp;defer&nbsp;attribute specifies that a script is executed when a page has finished the parsing. It is a boolean attribute. This attribute works for external scripts and must be used only when the&nbsp;src&nbsp;attribute is present. There isn\u2019t any difference between HTML 4.01 and\u00a0HTML5. In\u00a0XHTML, the\u00a0defer\u00a0attribute must be specified as\u00a0&lt;script defer=\u201ddefer\u201d>\u00a0as attribute minimization is forbidden. You [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[327],"tags":[],"_links":{"self":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts\/9359"}],"collection":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/comments?post=9359"}],"version-history":[{"count":0,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts\/9359\/revisions"}],"wp:attachment":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/media?parent=9359"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/categories?post=9359"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/tags?post=9359"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}