The async attribute
<script async src="script.js">
Because the loading of the script and the execution of the HTML are done in parallel, your browser finishes rendering earlier and the page is displayed faster. Async is perfectly suited for scripts that run independently and can be executed immediately. For example: advertisements or Analytics.
The defer attribute
<script defer src="script.js">
The defer attribute ensures that the browser no longer blocks while loading the script and postpones the execution of the script until the html is executed.
This means that the browser finishes executing the html earlier and can paint the page on the screen a lot faster.
Disadvantage: dependence on previous scripts
Disadvantage: not directly on the screen