Open In App

HTML DOM Script defer Property

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 a <script> Tag. This attribute is only used for External JavaScript File. 

Syntax: 



scriptObject.defer
scriptObject.defer = true|false

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

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



Example: This Example returns the defer Property. 




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

Output: 

 


Article Tags :