JavaScript defer Attribute

Yes! It's that easy, To load a JavaScript page you don't need anything libraries to load which beat the purpose of avoiding to load JavaScript files 'above the fold' I used to use a little library called LAB.js - It works great. However, you have to pre-load the JavaScript before the HTML content has been completely loaded. To use the defer attribue is very simple. Here is the usage and an example you can use:

defer Usage

To use the defer attribute in the <script> tag, here is a simple example:

 <script src="example.js" defer></scrip>

That is all. The defer is a Boolean type attribute. IT tells the browser to execute the specified JavaScript file after the pages has parsed. Be sure to use defer only when the src="" attribute is present. Otherwise, there is no need to use defer.

You can use the defer attribute for asynchronous loading. If the src="" is present and the defer is missing, the browser will immediately load the JavaScript file.