Skip to content
FunnelGuard

Fix guide by FunnelsGuard

Render-blocking JavaScript in head: how to find and fix it

PRF-012Medium impactPartlyBy FunnelGuardPublished Updated
On this page

What this issue is

When a browser reads your HTML and meets a normal <script src="..."> in the <head>, it pauses building the page. It downloads the file, runs it, and only then carries on. That is called render-blocking.

Typical offenders are jQuery, jQuery plugins, slider or carousel libraries (Slick, Owl Carousel, Revolution Slider, Swiper bundles), and theme scripts loaded in the head by default. Lighthouse reports this as "Eliminate render-blocking resources".

Why it costs you leads or sales

Visitors see a blank or half-drawn page until the scripts finish. On a slow phone connection that delay can be long. LCP, the time until the biggest visible element (often the hero image or headline) appears, gets later, and people leave before your form or buy button shows up.

The problem is worst on paid landing pages, where each click costs money and visitors are impatient. It is also easy to miss, because on your fast office connection the page may look fine.

How a blocking script delays the page
  1. HTML startsBrowser begins reading the head
  2. Blocking scriptjQuery or slider file downloads and runs
  3. Hero rendersLCP element appears late
  4. Form or button usableVisitor may already have left

The browser waits at the script and everything after it is delayed.

LCP before and after deferring scriptsExample numbers
LCP before and after deferring scripts (example)Blocking scripts in head: 4.1 seconds; Scripts deferred: 2.4 seconds0234.12.4Blocking scripts in h…Scripts deferredseconds

Example: illustrative numbers for a mobile test of one landing page, not measured results.

How to check if your site has it

Find blocking scripts
  1. Run Lighthouse or PageSpeed Insights

    Test your landing page on mobile. Open the "Eliminate render-blocking resources" item and note the script URLs listed.

  2. View the page source

    Right-click the page, choose View Page Source, and search for <script. Any tag inside <head> with a src and no defer or async is blocking.

  3. Use the Network tab

    In Chrome DevTools, open Network, reload with throttling set to Fast 4G or Slow 4G, and see which JavaScript files finish before the first paint.

  4. Spot the cause

    Check whether the files are jQuery, a slider, or a tag manager snippet. Each needs a slightly different fix.

What a blocking script looks likehtml
<head>
  <script src="/js/jquery.min.js"></script>
  <script src="/js/slider.js"></script>
</head>

How to fix it

The goal is to let the browser keep drawing the page while scripts download. Use defer for scripts that need the page structure and must run in order (jQuery and its plugins). Use async only for independent scripts. Defer keeps execution order, async does not.

Deferred scripts keep their orderhtml
<head>
  <script src="/js/jquery.min.js" defer></script>
  <script src="/js/slider.js" defer></script>
</head>
Defer scripts by platform
  1. Try your optimisation plugin

    If you use a performance plugin (for example WP Rocket, LiteSpeed Cache or Perfmatters), look for the option to defer JavaScript and exclude anything that breaks.

  2. Or add defer in code

    Use the script_loader_tag filter in your child theme or a small plugin to add defer to chosen handles, as in the snippet below.

  3. Test the slider and forms

    Clear caches and check that the slider, menu and forms still work.

WordPress: add defer to chosen scriptsphp
add_filter( 'script_loader_tag', function ( $tag, $handle ) {
    $defer = array( 'jquery-core', 'my-slider' );
    if ( in_array( $handle, $defer, true ) && false === strpos( $tag, ' defer' ) ) {
        return str_replace( ' src=', ' defer src=', $tag );
    }
    return $tag;
}, 10, 2 );

How to confirm it's fixed

After the change
  • Re-run PageSpeed Insights on mobile and check the render-blocking item is gone or smaller
  • LCP has improved compared with your earlier test
  • Open the browser console and confirm there are no "$ is not defined" errors
  • The slider, menu, popups and form still work
  • Submit a test lead and check it arrives
  • Check on a real phone, not only on desktop

How to prevent it happening again

Keep scripts under control
  • Add scripts with defer by default
  • Review the head code whenever a plugin, app or tool is added
  • Remove plugins and libraries you no longer use
  • Run a mobile Lighthouse test after every theme or plugin update
  • Keep a short list of who owns each script on the page

How FunnelGuard handles this

FunnelGuard detects this issue only partly. When a funnel page loads slowly, the problem shows up as a slow LCP on that step. FunnelGuard does not name the cause, so it will not tell you that a specific jQuery or slider script in the head is the reason.

To cover the rest by hand, use the LCP flag as your trigger. Then run PageSpeed Insights or Lighthouse on the same page, open "Eliminate render-blocking resources", and follow the checks above. After you fix it, FunnelGuard keeps running your journeys on a schedule, so you can see whether the step stays fast and whether forms and buttons still work after the script change.

The Free plan covers 1 site and 2 journeys with daily checks and no card. A free read-only website audit is also available.

Questions people ask

What does render-blocking JavaScript mean?

It means a script in the head that the browser must download and run before it can show the rest of the page. Until it finishes, visitors see a blank or partly drawn page. Adding defer or moving the script lower lets the page appear first.

Why is jQuery slowing down my website?

If jQuery is loaded as a plain script tag in the head, the browser pauses rendering to fetch and run it. Slider plugins that depend on it add more waiting. Load it with defer, or remove it if only a little code needs it.

What is the difference between async and defer?

Both download the script without blocking the page. defer runs scripts after the HTML is parsed and keeps their order, which suits jQuery and plugins. async runs each script as soon as it arrives, in any order, so use it only for independent scripts.

How do I eliminate render-blocking resources in WordPress?

Use a performance plugin's option to defer JavaScript, or add defer through the script_loader_tag filter. Exclude any script that breaks the site, then test the slider, menu and forms. Clear your caches before you re-test.

Why does adding defer to jQuery break my site?

Inline code that calls jQuery runs before the deferred file has loaded, so the browser reports "$ is not defined". Move the inline code into a deferred file or run it inside a DOMContentLoaded listener.

Does render-blocking JavaScript hurt LCP?

Yes. Blocking scripts delay when the browser can draw the page, so the largest element appears later and LCP rises. The effect is bigger on slow mobile connections.

Can FunnelGuard tell me which script is blocking my page?

No. FunnelGuard flags the slow LCP on the funnel step but does not name the cause. Use PageSpeed Insights or Lighthouse on that page to find the blocking script.

Does FunnelGuard catch this?

Partly

FunnelGuard checks part of this.

How: shows as LCP, cause not named.

Stop finding out from your customers

FunnelGuard runs your real forms and checkouts on a schedule, checks the tracking and the leads behind them, and alerts you once, with a screenshot. Try any paid plan free for 3 days.