Skip to content
AbsoluteFirst

Guides / Speed

Scripts in the page head delay the first paint

A script in the head without defer stops the page from drawing until it has downloaded and run.

Why it matters

When a browser meets a plain script tag in the head, it stops building the page, downloads the script, runs it, and only then continues. Several of these in a row mean the visitor looks at a blank screen while files they may not even need are fetched one after another.

This directly delays Largest Contentful Paint, the Core Web Vital that measures when the main content becomes visible.

How to fix it

  1. Add the defer attribute to scripts that do not need to run before the page is visible. Deferred scripts download in parallel and run after the HTML is parsed, in order.
  2. Use async for independent scripts such as analytics.
  3. Remove scripts for tools you no longer use. Old chat widgets and tracking pixels are the usual suspects.
Before and after (example)
<!-- blocks rendering -->
<script src="/js/slider.js"></script>

<!-- does not -->
<script src="/js/slider.js" defer></script>

How we check it

We re-read each page and count head scripts without async or defer.

Where it sits in the plan

Stage 4 of 5, “Keep the visitor”. Speed and stability matter most once people are arriving. These fixes protect the traffic the earlier stages earn.

Typical effort: about 2 hours. In plain terms: ask your developer to defer scripts that are not needed immediately.

Does your site have this problem?

Scan it and see the evidence from your own pages.

Related guides