Sitemap
softAai Blogs

Explore in-depth insights on Kotlin, Android, Java, DSA, Design Patterns, Architectures, AI/ML, and Automotive/IVI. Discover best practices and knowledge all in one place: https://softaai.com/

Follow publication

Member-only story

Defer vs Async in JavaScript: What’s the Best Way to Load Scripts?

3 min readApr 26, 2025

--

When it comes to optimizing website performance, how you load JavaScript files can make a big difference. One of the most common questions developers ask is: Defer vs Async — which should I use to load scripts?” In this guide, we’ll show you how both work, and help you choose the right one.

Why Script Loading Matters

JavaScript is powerful, but if it’s not loaded properly, it can slow down your site. When a browser encounters a <script> tag, it has to decide whether to load it immediately or continue parsing the HTML.

Traditionally, scripts block the rendering of the page. That means users wait longer to see content. This is where defer and async come in.

Understanding the Basics

There are three common ways to load external scripts in HTML:

<script src="script.js"></script>        <!-- Default behavior -->
<script src="script.js" defer></script> <!-- Defer -->
<script src="script.js" async></script> <!-- Async -->

Each one tells the browser something different about when and how to load the JavaScript.

Default Script Loading

--

--

softAai Blogs
softAai Blogs

Published in softAai Blogs

Explore in-depth insights on Kotlin, Android, Java, DSA, Design Patterns, Architectures, AI/ML, and Automotive/IVI. Discover best practices and knowledge all in one place: https://softaai.com/

amol pawar
amol pawar

Written by amol pawar

Senior Android Developer | Software Engineer https://softaai.com/

No responses yet