Guide

Delay JavaScript in WordPress without breaking things

Delaying scripts until the visitor interacts can transform your mobile score. Here is how it works, what to delay and what to keep.

“Delay JavaScript” means a script doesn’t run when the page loads—it waits until the visitor first moves the mouse, scrolls, taps or presses a key. The page appears and becomes usable sooner, and lab tests like PageSpeed see far less blocking time.

Defer vs async vs delay

  • Async: download in parallel, run as soon as downloaded—order not guaranteed.
  • Defer: download in parallel, run after the HTML is parsed, in order.
  • Delay: don’t even download until the first interaction. The biggest savings, and the one that needs the most care.

Good candidates to delay

  • Chat widgets and support bubbles
  • Analytics, tag managers and advertising pixels
  • Embedded videos and maps below the fold
  • Cookie banners from third-party services (if they don’t need to show before interaction)
  • Reviews widgets and social feeds

Scripts to keep running

  • Anything that builds what’s visible in the first screen (a hero slider, a menu that must open on the first tap)
  • Consent tools that must run before other tracking
  • Payment and checkout scripts

Avoid the common breakages

Delayed scripts that depend on DOMContentLoaded or jQuery’s ready event may never see those events fire. A good delay implementation replays them, runs scripts in their original order and keeps jQuery available for scripts that need it. It should also yield between scripts, so the visitor’s first tap is answered immediately instead of freezing while everything runs at once.

How FastFront does it

FastFront delays third-party scripts automatically, keeps their order, replays load events and runs them in small steps after the first tap is shown—so the page answers instantly. On Elementor pages it goes a step further and replaces jQuery and Elementor’s frontend scripts with a small runtime, so there is much less JavaScript left to delay.

More speed guides

Not using FastFront yet?

See your own site’s score next to an optimized copy—free, in about a minute.