By default, scripts are loaded and executed as soon as the HTML parser encounters them in the HTML file, the HTML parser waits to load the entire script before from proceeding to parse the rest of the page elements.
deferattribute ensures that the entire HTML file has been parsed before the script is executed.
asyncattribute will allow the HTML parser to continue parsing as the script is being downloaded, but will execute immediately after it has been downloaded.
The old convention was to put scripts right before the
</body> tag to prevent the script from blocking the rest of the HTML content. Now, the convention is to put the script tag in the
<head> element and to use the
Congratulations on completing this lesson!