Playbook
performance
medium
Fix render-blocking JavaScript
Render-blocking scripts in your <head> are holding back First Paint. Here is how to defer or async every one.
25 minutesLast reviewed 2026-06-09
What is happening
Every <script src="..."> in <head> without async or defer blocks the browser from rendering the page until the script downloads and executes. Lighthouse flags these in "Eliminate render-blocking resources" — they often add 1–3 seconds to First Contentful Paint.
Fix it
defer downloads the script in parallel and executes after the HTML is parsed.async is fire-and-forget — order is not guaranteed, but the script never blocks render.DOMContentLoaded listener.Cheat sheet
<script src> → defaults to blocking. Always add defer or async.<script defer src> → downloads in parallel, runs in order, after parse. Use for app scripts.<script async src> → downloads in parallel, runs as soon as ready. Use for analytics.<script type="module" src> → defers by default. Modern modules are safe.Common gotchas
document.write after page parse wipes the document. Refactor or remove.What this doesn't do
This is for render-blocking scripts. For unused JavaScript bytes, code-split with dynamic imports. For long tasks blocking the main thread, see Total Blocking Time fixes.