Test website speed
When designing websites, it is important to produce the fastest loading experience for your visitors. For most websites, this means getting the first screenful of content (also known as above the fold) to visitors as quickly as possible. A goal for most web developers is to get the first screen loaded within two seconds. We use tools like GTmetrix and PageSpeed Insights to measure how fast a web page loads.
Async vs Defer
There are two methods used to download JS files. The first (and default) method is to use the async attribute. This tells browsers to load files as it finds them in the web page coding. Most times, JS loads in the head or the foot of the web page. Either way, the JS file must completely load before displaying the web page.
There are two things to be aware of when deferring the loading of JS files. First, you must manually tell the browser to defer the JS files. Second, WordPress relies on some JS files (especially jQuery.js) for the operation of its software. Carefully selecting and testing which JS files to defer is crucial if you want the ensure that critical components of your website are available for visitors.