As you want to know what is the difference between async and defer experts and when and where they should be used. So for this you read this post, maybe you can get some information about async and defer by this article.
Why are async and defer used?
So to avoid this, so that a script does not block the rendering process of the browser, scripts are used with the async or defer attributes, so that that script is rendered or processed later in the rendering process.
The async and defer attributes are optional attributes for the <script> tag that instruct the browser to download the indicated file at a lower priority in the background without interrupting the page rendering process.
Any resource provided on a page is first downloaded and then displayed or played on the page. Whereas async and defer have the same loading behavior – loading in the background without render blocking.
Where not to use async and defer attributes
Function of defer
The effect of the defer attribute is similar to that of placing a traditional <script> reference at the bottom of HTML before the closing </body> tag. The advantage of defer is that <script> can be placed in the to be searched and can start loading sooner if the page has fewer resources.
When to use async
In the interest of page speed, async should be used with caution and generally only for files on which the initial rendering of the page depends.
When to use defer
How to add async or defer attribute to script
The async or defer attribute in a script also depends on the type of CMS, but the async and defer attributes are often added to the script, something like this:
<script async src="super-high-priority.js"></script>
<script defer src="general-stuff.js"></script>
<script async='async' src='https://www.googletagmanager.com/gtag/js?id=UA-209154083-2'/>
<script async='async' src='https://cdn.onesignal.com/sdks/OneSignalSDK.js'/>
<script defer='defer' src='https://cdn.onesignal.com/sdks/OneSignalSDK.js'/>
Whichever method your theme supports, you can use the async or defer attribute.
Thanks for reading: Difference between async and defer, Use of async and defer, Please, share this article. If this article helped you, then you must write your feedback in the comment box.