SOLVED – How to Load JavaScript Files Asynchronously

Is your Google PageSpeed score is low and you want to increase this score? There’s e little trick for your javascript files.

If you use common javascript files which means thousands of website uses the same library, there’s a special network named CDN. With the files stored within CDN areas are really useful for sharing browser caches.

Files stored under CDN allow a user to cache this file for first visit. After visiting another website, if the same file is referenced again if already cached, this fiile will not be loaded again, it will be used from browser cache.

So, if our JavaScript file is not located in CDN or it’s the file that we have created. There’s an asynchon method.

async Parameter for Script Files

Just replace this code:

<script type="text/css" src="file.js">

… to this one:

<script async type="text/css" src="file.js">

That’s all!

Add a Comment

Your email address will not be published. Required fields are marked *