<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/async-vs-defer-in-javascript-which-is-better--rjwmqpqo5" -->

---
title: Async vs Defer in JavaScript: Which is Better?🤔 | daily.dev
description: Learn about the async and defer attributes used when including external JavaScript files in HTML documents. Understand their differences, how they affect...
canonical: https://daily.dev/posts/async-vs-defer-in-javascript-which-is-better--rjwmqpqo5
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Async vs Defer in JavaScript: Which is Better?🤔 | daily.dev
og:description: Learn about the async and defer attributes used when including external JavaScript files in HTML documents. Understand their differences, how they affect...
og:url: https://daily.dev/posts/async-vs-defer-in-javascript-which-is-better--rjwmqpqo5
og:image: https://api.daily.dev/og/posts/rJWMQPqO5.png
og:image:alt: Async vs Defer in JavaScript: Which is Better?🤔
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Async vs Defer in JavaScript: Which is Better?🤔

**[DEV](https://daily.dev/sources/devto)** · [@fidalmathew](https://daily.dev/fidalmathew) · 2 min read · 634 upvotes · 34 comments

## Summary

Learn about the async and defer attributes used when including external JavaScript files in HTML documents. Understand their differences, how they affect script execution, and when to use them.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://dev.to/fidalmathew/async-vs-defer-in-javascript-which-is-better-26gm>

## Community discussion

Top comments from developers on daily.dev.

**@matyleo** · 8 upvotes

> Helpful explanation that gets straight to the point! Nice little art.

**@minhnh** · 4 upvotes

> concise, easy to digest. we should have more articles like this!

**@ivanlynch** · 2 upvotes

> Nice post!

**@sudouken** · 2 upvotes

> This article is a great overview. For a deeper dive, particularly into the `DOMContentLoaded` event check out this article:
>
> https://javascript.info/script-async-defer

**@muhammadidrees** · 1 upvotes

> impresive

## Similar posts on daily.dev

- [Don’t just attend KubeCon \+ CloudNativeCon, Merge Forward your experience\!](https://daily.dev/posts/don-t-just-attend-kubecon-cloudnativecon-merge-forward-your-experience--l0rpp73x8) · CNCF · 1 upvotes · 0 comments
- [Announcing H2 2026 KCDs](https://daily.dev/posts/announcing-h2-2026-kcds-m96goajm1) · CNCF · 1 upvotes · 0 comments
- [Two months of Open Community Groups](https://daily.dev/posts/two-months-of-open-community-groups-asf52zhbs) · CNCF · 0 upvotes · 0 comments
- [CNCF Unveils Schedule for KubeCon \+ CloudNativeCon Europe 2026](https://daily.dev/posts/cncf-unveils-schedule-for-kubecon-cloudnativecon-europe-2026-ikhcoa5cb) · CNCF · 2 upvotes · 0 comments
- [CNCF Debuts KubeCon \+ CloudNativeCon Japan 2026 Schedule](https://daily.dev/posts/cncf-debuts-kubecon-cloudnativecon-japan-2026-schedule-xp5pyudub) · CNCF · 1 upvotes · 0 comments

---

Tags: [#webdev](https://daily.dev/tags/webdev), [#javascript](https://daily.dev/tags/javascript), [#performance](https://daily.dev/tags/performance), [#html](https://daily.dev/tags/html)

[View this post on daily.dev](https://daily.dev/posts/async-vs-defer-in-javascript-which-is-better--rjwmqpqo5)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Async vs Defer in JavaScript: Which is Better?🤔","url":"https://daily.dev/posts/async-vs-defer-in-javascript-which-is-better--rjwmqpqo5","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/async-vs-defer-in-javascript-which-is-better--rjwmqpqo5"},"datePublished":"2024-03-01T18:35:46.689Z","dateModified":"2024-05-09T08:43:33.910Z","description":"Learn about the async and defer attributes used when including external JavaScript files in HTML documents. Understand their differences, how they affect...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/42b86f0c062557eea2dc7bdd3eba3ea6?_a=AQAEufR","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/42b86f0c062557eea2dc7bdd3eba3ea6?_a=AQAEufR","isAccessibleForFree":true,"articleSection":"DEV","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Person","name":"Fidal Mathew","url":"https://daily.dev/fidalmathew","image":"https://media.daily.dev/image/upload/f_auto/v1637466439/avatars/yQxAY4oS4AZmzn2OWaaef","description":"Student | Web developer, learning to become a MERN stack developer | Love to connect with other developers","interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"EndorseAction"},"userInteractionCount":420}},"commentCount":34,"discussionUrl":"https://daily.dev/posts/async-vs-defer-in-javascript-which-is-better--rjwmqpqo5","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":634},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":34}],"keywords":"webdev,javascript,performance,html","timeRequired":"PT2M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"DEV","item":"https://daily.dev/sources/devto"},{"@type":"ListItem","position":3,"name":"Async vs Defer in JavaScript: Which is Better?🤔"}]}
{"@context":"https://schema.org","@type":"WebPage","@id":"https://daily.dev/posts/async-vs-defer-in-javascript-which-is-better--rjwmqpqo5","comment":[{"@type":"Comment","text":"Helpful explanation that gets straight to the point! Nice little art.","datePublished":"2024-03-02T13:45:26.447Z","url":"https://daily.dev/posts/rJWMQPqO5#c-rzWnojgOB","author":{"@type":"Person","name":"Matyáš Leon Dušek","url":"https://daily.dev/matyleo","image":"https://lh3.googleusercontent.com/a/ACg8ocIcBWmZEyEi-uGxy1pOog9ZUFQoRua_rGNMDR2lAzHevzI=s96-c"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":8}},{"@type":"Comment","text":"concise, easy to digest. we should have more articles like this!","datePublished":"2024-03-04T02:18:10.363Z","url":"https://daily.dev/posts/rJWMQPqO5#c-Pg6qkSOJ2","author":{"@type":"Person","name":"Minh Nguyen","url":"https://daily.dev/minhnh","image":"https://avatars.githubusercontent.com/u/6817741?v=4"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":4}},{"@type":"Comment","text":"Nice post!","datePublished":"2024-03-02T18:10:38.982Z","url":"https://daily.dev/posts/rJWMQPqO5#c-xkyWkU9oT","author":{"@type":"Person","name":"ivanlynch","url":"https://daily.dev/ivanlynch","image":"https://media.daily.dev/image/upload/s--XvTPvuHQ--/f_auto/v1707839958/avatars/avatar_G8nDHTKFt9FXLQAWHIZEA"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":2}},{"@type":"Comment","text":"This article is a great overview. For a deeper dive, particularly into the DOMContentLoaded event check out this article:\nhttps://javascript.info/script-async-defer","datePublished":"2024-03-04T05:36:42.197Z","url":"https://daily.dev/posts/rJWMQPqO5#c-SAGtYA9o3","author":{"@type":"Person","name":"Matthew","url":"https://daily.dev/sudouken","image":"https://media.daily.dev/image/upload/s--jRwVjerf--/f_auto/v1755725028/avatars/avatar_l1V0jO5VncYwbcQDE0JQ1?_a=BAMClqZW0"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":2}},{"@type":"Comment","text":"impresive","datePublished":"2024-03-04T02:32:37.716Z","url":"https://daily.dev/posts/rJWMQPqO5#c-y5Ijdnsq3","author":{"@type":"Person","name":"Muhammad Idrees","url":"https://daily.dev/muhammadidrees","image":"https://lh3.googleusercontent.com/a/ACg8ocIWVN8uV0JvuYtf42i8DDuAfQhRXk3J6XY_pRMY_U91=s96-c"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":1}}]}
```

