How exactly does

The defer attribute is used to specify that the script execution occurs when the page loads. It is used only for external scripts and is a boolean attribute.


The following code shows how to use the defer attribute:

Live Demo

<!DOCTYPE html>
      <script src="defer_test.js" defer></script>
      <p>The external file added will load later, since we're using defer</p>
Samual Sam
Samual Sam

Learning faster. Every day.