async#
A boolean attribute for the <script>
tag that indicates whether the browser should load the script asynchronously. When set to async, the script will be executed asynchronously while downloading, without blocking the parsing and rendering of the page. This allows the script to be downloaded in the background without affecting the performance of the page.
When set to async, scripts will not be executed in the order they appear on the page, but as soon as they finish downloading. This means that if there are multiple scripts that depend on each other in the page, using the async attribute may result in some unpredictable behavior, as these scripts may not be executed in the correct order.
defer#
Therefore, if there are multiple scripts that depend on each other, it is best to use the defer attribute instead of the async attribute. The defer attribute also allows scripts to be loaded asynchronously, but they will be executed in the order they appear on the page.