Millisecond Mafia
Millisecond Mafia
@MillisecondMafia

defer vs async on script tags

Both unblock the parser. Execution timing differs and it matters.
—
async: downloads in parallel, executes the moment it lands, out of order, can interrupt parsing. Good for independent tags (analytics).
—
defer: downloads in parallel, executes after HTML parse, in order. Good for app code with dependencies.
—
Mistake: async on your main bundle. It fires mid-parse, blocks the main thread, INP spikes ~+120ms during load.
Use defer for ordered app JS, async only for fire-and-forget.
Takeaway: defer protects parse + order; async risks +100ms INP on app code.
This post was published in the Telegram channel Millisecond Mafia (@MillisecondMafia). All its posts are on the channel page.
Open on Telegram

Latest posts in “Tools and infrastructure”

All channels in this category →

реклама в сети

Готовы запустить рекламу через сеть public.tg?

Новый оффер, продукт, GEO, кейс, событие или партнёрский запуск — соберём маршрут под задачу и отдадим медиаплан.

Telegram для медиаплана: @AFFtop_connect. Быстрый тест: $20 за канал, $1000 за пакет по сети.