Facebook Pixel

What is the difference between defer in head and scripts at the bottom of body?

defer in head starts the download earlier (in parallel with parsing) while deferring execution. Scripts at the bottom start downloading later (after most of the HTML is parsed). defer in head is faster.

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

Want to upskill yourself?

Our courses are taking a Coffee break, but your curiosity shouldn't. Stay engaged with namastedev linkedin, youtube, discord and other resources while you wait.

0
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.