Deferring JavaScript for Faster Page Loads

A browser network timeline on a monitor with scripts finishing after the page appears

JavaScript is the most expensive resource on the web. Unlike images and CSS, which can be downloaded and processed in parallel, JavaScript blocks the browser’s main thread. While a script is executing, nothing else can happen — no rendering, no interaction, no scrolling. Deferring non-critical JavaScript is one of the highest-impact optimizations you can make.

The Problem with Synchronous JavaScript

By default, when the browser encounters a <script> tag in the HTML, it stops everything, downloads the script, parses it, and executes it — before continuing to parse the rest of the page. If the script is large or the network is slow, the visitor stares at a blank screen while the browser waits.

WordPress sites are particularly prone to this problem. A typical site loads JavaScript from the theme, the block editor, multiple plugins, analytics services, chat widgets, and ad networks. Each one is a potential bottleneck.

Defer and Async: The Two Solutions

HTML provides two attributes that change how scripts load: defer and async. Both prevent the script from blocking the HTML parser, but they differ in execution timing.

  • defer — The script downloads in the background while the page continues to render. It executes only after the HTML is fully parsed, and multiple deferred scripts execute in the order they appear in the document. Use defer for scripts that depend on the DOM being ready or on other scripts.
  • async — The script downloads in the background and executes as soon as it is ready, regardless of whether the HTML is fully parsed. Async scripts can execute in any order. Use async for independent scripts like analytics and ads.

Caching Out can add defer attributes to your scripts — one toggle, with a per-script exclusion list for anything that must load synchronously. For example, A/B testing scripts that need to run before the page renders to prevent flickering.

Measuring the Impact

The metric most affected by JavaScript optimization is Interaction to Next Paint (INP). Every long-running script delays the browser’s ability to respond to user input. After deferring non-critical JavaScript, run a PageSpeed Insights test and compare your INP score. A noticeable reduction is common on sites that were loading multiple synchronous scripts.

Further reading: Render-blocking CSS, explained for the CSS half of the render-blocking problem.

More from the blog

Ready when you are

One plugin, every optimisation, from $59 a year.

Install it, turn on what you need, and measure the difference on your own site. If it does not do what this site says, the 14-day guarantee means you get your money back.

  • No code required
  • Setup in under 3 minutes
  • 14-day money-back guarantee
  • 14-day money-back guarantee
  • Works on standard shared and managed hosting
  • Cancel anytime

Free edition · WordPress.org

Get Caching Out for free

Good call. Page caching is the biggest single speed win, and it is on the moment you activate. Two ways to install the free edition:

Option 2

Upload the zip

Download the plugin zip, then go to Plugins → Add New Plugin → Upload Plugin and choose the file.

Download free plugin (.zip)

After you activate, caching is already running. Open Caching Out → Setup Wizard to see what is on and why.

Want every feature from day one? Pro from $59/yr