Mark script element as defer

Description

defer attribute on a <script> element tells browser that download should begin immediately but execution should be deferred:

Example


<!DOCTYPE html>
<html>
  <head>
    <script type="text/javascript" defer src="example1.js"></script>
    <script type="text/javascript" defer src="example2.js"></script>
  </head>
  <body>
    <!-- content here -->
  </body>
</html>

Note

The defer attribute is supported only for external script files.

For XHTML documents, specify the async attribute as defer="defer".





















Home »
  Javascript »
    Javascript Introduction »




Script Element
Syntax
Data Type
Operator
Statement
Array
Primitive Wrapper Types
Function
Object-Oriented
Date
DOM
JSON
Regular Expressions