PageSpeed : Prefer asynchronous resources

Published

Fetching resources asynchronously prevents those resources from blocking the page load.

It is always a recommended tip to follow asynchronous method for loading external script files. thus it will speed up loading of page.


Why Asynchronous?

<script> tags will block HTML renderer if they are found in between any other elements.

If you are loading a huge JavaScript file with a blocking <script>  tag at the top of markup, you will not see any progress on the page as the mentioned script is getting loaded and evaluated.
Here adding async tag will help the performance.
if we tag with a aync, the browser will no longer stop the html renderer process,and it will load and evaluated the script block asynchronously.

How to  asynchronously load a script?

Adding an async attribute will do this job.

<script async="async" src="http://path-to-the-javascript-file.js"></script>


Comments