Should you use async for scripts with dependencies?
No. async does not guarantee execution order. If script B depends on A, use defer for both. defer guarantees order.
Verify This Answer
Cross-check this information using these trusted sources:
More FAQs in async and defer Best Practices
defer. It is non-blocking, executes in order, and runs after the DOM is ready. Use async only for independent scripts like analytics and ads.
In the <head>. This starts the download early (in parallel with HTML parsing) while deferring execution until after parsing. This is faster than placing scripts at the bottom of <body>.
Yes. <script type='module'> is automatically deferred. You do not need to add the defer attribute. The script downloads in parallel and executes after parsing.
Still have questions?
Browse all our FAQs or reach out to our support team
