Skip to content
FunnelGuard

Fix guide by FunnelsGuard

Long tasks over 50 ms blocking input: how to find and fix them

PRF-040Medium impactCould addBy FunnelGuardPublished Updated
On this page

What this issue is

The browser runs your page's JavaScript, layout and painting on one thread, called the main thread. It can only do one thing at a time. A long task is any task on that thread that runs for more than 50 ms. Chrome marks these with a red corner in the Performance panel.

While a long task runs, the browser cannot respond to input. A visitor who taps your button during that window sees nothing happen until the task finishes. Typical causes are large script bundles, tag manager containers, chat widgets, A/B testing tools and heavy page-builder scripts that all start at load.

What happens when a visitor taps during a long task
  1. Page starts loadingScripts begin to run
  2. Long task runsMain thread busy for hundreds of ms
  3. Visitor taps CTAInput is queued, no feedback
  4. Visitor taps again or leavesDouble submits or abandoned form

The tap is not lost at first, but it waits behind the long task.

Why it costs you leads or sales

Visitors on phones often arrive and act within seconds. If the page looks ready but ignores their first tap, they think it is broken. Some tap repeatedly, which can cause double submissions. Others leave. Slow input response is also part of the Interactivity (INP) measure that Google uses in its Core Web Vitals.

Longest task on the main thread vs. first-tap delayExample numbers
Longest task on the main thread vs. first-tap delay (example)Task 40 ms: 40 ms; Task 150 ms: 150 ms; Task 400 ms: 400 ms; Task 900 ms: 900 ms034569040150400900Task 40 msTask 150 msTask 400 msTask 900 msms

Example: illustrative numbers showing that the wait before a tap is handled grows with the length of the task it lands in.

How to check if your site has it

Find long tasks with Chrome DevTools
  1. Open the page in an Incognito window

    This keeps extensions from adding their own tasks to the results.

  2. Open DevTools and the Performance panel

    Press F12 (or Cmd+Option+I on Mac), then choose Performance. In the settings gear, set CPU to 4x slowdown to mimic a phone.

  3. Record a page load

    Click the reload-and-record button and wait until the page settles.

  4. Look at the Main track

    Tasks with a red triangle in the corner are over 50 ms. Click one and read the Bottom-Up or Call Tree tab to see which script owns the time.

  5. Cross-check with PageSpeed Insights

    Run your URL and read Total Blocking Time and the 'Avoid long main-thread tasks' diagnostic, which lists the longest tasks.

To log long tasks from real visits, you can use the browser's Long Task API. Paste this in the DevTools Console before the page finishes loading, or add it to a test page.

Log long tasks to the consolejavascript
new PerformanceObserver((list) => {
  for (const entry of list.getEntries()) {
    console.log('Long task:', Math.round(entry.duration) + ' ms', 'starts at', Math.round(entry.startTime) + ' ms');
  }
}).observe({ type: 'longtask', buffered: true });

How to fix it

The goal is to stop any single piece of work from holding the thread for long. You do that by running less code, running it later, or splitting it into smaller pieces. Start with the longest task and the script that owns it.

Shorten and split long tasks
  1. Remove scripts you do not need

    Delete old tags, unused widgets and abandoned plugins. Code that never loads costs nothing.

  2. Defer non-critical scripts

    Add defer or async to script tags that do not need to run before the page is usable. Load chat widgets and heatmaps after the page is interactive.

  3. Split big functions and yield

    Break loops and setup work into chunks and give the browser a chance to handle input between them.

  4. Code-split large bundles

    Load only the code the current page needs. Dynamically import features such as sliders or maps when they are used.

  5. Re-test with 4x CPU slowdown

    Record again and compare the number and length of red-marked tasks.

Yield to the browser between chunks of workjavascript
function yieldToMain() {
  if (globalThis.scheduler && scheduler.yield) {
    return scheduler.yield();
  }
  return new Promise((resolve) => setTimeout(resolve, 0));
}

async function processItems(items) {
  for (const item of items) {
    handle(item);
    await yieldToMain(); // lets pending taps and clicks run
  }
}
Where to act on each platform
  1. Find the heavy plugins

    In the DevTools Call Tree, note script file paths under /wp-content/plugins/. Deactivate or replace the worst offenders (sliders, page-builder add-ons, social feeds).

  2. Delay or defer scripts

    If you use a performance plugin, look for its option to defer JavaScript or delay it until first user interaction. Test your forms after enabling it, as it can break them.

Main thread during page load

Before

  • One 700 ms task runs the whole tag and app setup
  • Taps on the form button wait until it ends
  • Visitors tap twice or leave

After

  • Work split into short tasks under 50 ms
  • Non-critical scripts deferred until after load
  • Button responds on the first tap

How to confirm it's fixed

Confirmation checklist
  • Record the page again in DevTools with 4x CPU slowdown and compare the red-marked tasks
  • Run PageSpeed Insights and check that Total Blocking Time went down
  • Tap the main button and type into a form field right after load; the response feels instant
  • Submit a test lead and confirm it still arrives, since deferring scripts can break forms and tracking
  • Check your analytics tags still fire after moving them to later triggers

How to prevent it happening again

Prevention habits
  • Review the Performance panel each time you add a plugin, app or tag
  • Keep a list of who owns each third-party script and why it is there
  • Set a size budget for JavaScript on form and checkout pages
  • Re-run PageSpeed Insights monthly and after theme updates
  • Test on a mid-range phone, not only on a fast laptop

How FunnelGuard handles this

FunnelGuard does not check for long tasks yet. It does not record the Long Task API, so it will not tell you when a task passes 50 ms. This is a possible future check.

What FunnelGuard does do is run your real journeys on a schedule, such as lead forms, checkouts and booking or chat buttons. It checks each step, the tracking hits sent to ad and analytics platforms, and whether test leads reach your inbox and CRM. If a heavy script ends up breaking a step in the journey, that failure can show up there, but it is not a measure of main-thread blocking.

To watch for long tasks, use the DevTools Performance panel, PageSpeed Insights, or the console snippet above. Free plan: 1 site, 2 journeys, daily checks, no card. A free read-only website audit is also available.

Questions people ask

What is a long task in JavaScript?

A long task is any task that keeps the browser's main thread busy for more than 50 ms. While it runs, the browser cannot respond to clicks, taps or typing. Chrome marks long tasks with a red corner in the DevTools Performance panel.

Why does my page freeze for a moment while it loads?

Usually a large script, a tag manager container or a third-party widget is running as one long task on the main thread. The page may look ready but cannot respond until that work ends. Record a page load in DevTools Performance to see which script owns the time.

How do I find long tasks on my website?

Open Chrome DevTools, go to Performance, set CPU to 4x slowdown, and record a page load. Tasks with a red triangle are over 50 ms. Click one and open the Bottom-Up tab to see which script caused it. PageSpeed Insights also lists them under 'Avoid long main-thread tasks'.

How do I break up a long task?

Split the work into smaller chunks and yield to the browser between them, using scheduler.yield() where supported or a setTimeout fallback. You can also defer non-critical scripts, code-split large bundles, or move heavy work to a Web Worker.

Do long tasks affect Core Web Vitals?

Yes. Long tasks raise Total Blocking Time in lab tests and can slow Interactivity (INP), because input waits behind the running task. Both can be reported in PageSpeed Insights.

Does FunnelGuard detect long tasks?

No. FunnelGuard does not record the Long Task API yet, and it is only a possible future check. It does run your real journeys and check each step, tracking hits and test leads, so you can use DevTools or PageSpeed Insights alongside it for main-thread work.

Can deferring scripts break my forms or tracking?

It can. If a form or tag depends on a script you delayed, it may stop working or fire late. After any change, submit a test lead and check that your analytics tags still fire.

Does FunnelGuard catch this?

Could add

Not checked yet: could be added to FunnelGuard.

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.