Skip to content
Preptima
mediumConceptScenarioEntryMidSenior

A third-party script in the head delays your first paint by a second. What do async, defer and type="module" each change about parsing and execution order?

A plain script in the head stops the parser until it is fetched and run. defer fetches in parallel and runs after parsing, in document order, before DOMContentLoaded. async runs as soon as it arrives, in no guaranteed order. Module scripts are deferred by default and also accept async.

5 min readUpdated 2026-10-09Target archetype: Big Tech, Product Startup

Answer

Short answer

A plain <script src> in the head is parser-blocking. The parser stops, the browser fetches and runs the file, and only then carries on building the page, so a slow third-party host delays first paint. The async vs defer choice changes script loading and execution timing, not whether the script runs:

ScriptFetchRunsOrderDOMContentLoaded
plainblocks the parserimmediatelydocument orderwaits for it
deferin parallelafter parsing finishesdocument orderwaits for it
asyncin parallelas soon as it arrivesnone guaranteeddoes not wait
type="module"in parallel, with importsafter parsing finishesdocument orderwaits for it
type="module" asyncin parallel, with importsas soon as the graph arrivesnone guaranteeddoes not wait

Was this answer helpful?

Likely follow-ups

  • The vendor's snippet injects its script with createElement instead of a script tag. Which of these behaviours does the injected script get?
  • A deferred script registers a DOMContentLoaded listener and it fires. The same code marked async sometimes never sees the event. Why?
  • Moving the vendor tag to type=module broke it with a network error that never happened as a classic script. What changed about the request?
  • Would you self-host the third-party file to avoid the extra connection, and what do you lose by doing it?

Related questions

Further reading