Deferred Scripts

The defer attribute tells that the script can be run safely after the entire page has been parsed. The browser would download the script immediately but execution should be deferred:

 
<!DOCTYPE html> 
<html> 
<head> 
    <title>Example HTML Page</title> 
    <script type="text/javascript" defer src="example1.js"></script> 
    <script type="text/javascript" defer src="example2.js"></script> 
</head> 
<body> 

</body> 
</html>
  
Click to view the demo

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

Home 
  JavaScript Book 
    Language Basics  

Script Element:
  1. Getting Ready to Use JavaScript and <SCRIPT> ELEMENT
  2. Deferred Scripts
  3. Asynchronous Scripts
  4. <NOSCRIPT> ELEMENT
  5. Using Statements