The async attribute is a boolean attribute. When present, it specifies that the script will be executed asynchronously as soon as it’s available.
<script async src="script.js"></script>
The defer attribute is a boolean attribute that specifies that the script should be executed after the document has been parsed, but before firing DOMContentLoaded.
<script defer src="script.js"></script>
The “Delayed” method allows the script to only be loaded and executed when the user interacts with the page in a certain way (like scrolling or clicking). This method can be particularly useful for scripts that are not necessary for the initial rendering of the page.
<script data-type="lazy" data-src="script.js"></script>
If there is no user action in 5 seconds, it will execute the JS after reaching the time limit.