Let us begin with the definition of terms:
- A parser is your HTML in loading state
- The time that your script is being loaded to life is referred to as the net
- The time your script is brought to life in your user’s browser is referred to as execution
Ordinarily, a website pauses the HTML parsing while the scripts are executing. Therefore, there will be a delay before users your HTML in terms of design, content etc.
Deferring your script defined Increase Website Speed
Simply put, deferring your script is letting all the HTML load on your user’s browser before the execution of the tasks begins. Your website will in fact appear on the user’s web browser which seems to show that your website has a fast loading speed. A deferred script is most useful when some of your users do not use browsers that support asynchronous script loading.
Asynchronous loading of scripts to Increase Website Speed
The best way to optimize your website speed is to by both deferring scripts and synchronous script loading. When using these two attributes, there are three possible modes, including:
- A Present async attribute means that the script will be executed asynchronously as soon as it is available
- If the async attribute is absent but the defer attribute is present then the script is executed when parsing of the website is completed
- When neither attribute is present, the script is immediately fetched and executed before the user agent continues parsing the page
Important note to Increase Website Speed
Defer and async tags are available for external scripts only. These are scripts with the src=”” tag. Defer and async tags will be ignored for any use in internal scripts. Internal scripts are like <script>…</script> tags.