Skip to content
Related Articles

Related Articles

HTML | DOM Script defer Property

View Discussion
Improve Article
Save Article
  • Last Updated : 20 Oct, 2020

The Script defer Property is used to set or return whether the script should be executed after the page has finished parsing. This Property is used to reflect the defer attribute of an <script> Tag.
This attribute is only used for External JavaScript File.


  • It Return the defer property.
  • It is used to set the defer property
    scriptObject.defer = true|false

Property Values: It contains the Boolean value which specify that whether a script should be executed when the page has finished parsing, or not

  • true: The script is executed when the page has finished parsing
  • false: The script will not be executed when the page has finished parsing.

Return Values: It returns a boolean value, returns true if the script is executed after the loading of the page is finished.

Example: This Example returns the defer Property.

<!DOCTYPE html> 
        DOM script defer Property 
<body style="text-align:center;"
        DOM script defer property
    <script id="myGeeks" type="text/javascript" 
            src="my_script.js" defer>
    <button onclick="Geeks()">Submit</button>
    <h2 id="demo"></h2>
                 function Geeks()  {
          var x = document.getElementById("myGeeks").defer;
  document.getElementById("demo").innerHTML =  x;


Before Clicking On Button :

After Clicking On Button :

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!