How to load the script asynchronously in JavaScript
Loading non-critical scripts asynchronously can speed up our websites.
Nowadays, to do this, we don’t need any magic tricks, and long, weird codes, because modern browsers should support the async
.
All we have to do is to add the async
to our script.
To do so, just change this:
<script src="https://snippetsdb.com/examplescript.js"></script>
To this:
<script src="https://snippetsdb.com/examplescript.js" async></script>