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.
- Page starts loadingScripts begin to run
- Long task runsMain thread busy for hundreds of ms
- Visitor taps CTAInput is queued, no feedback
- 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.
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
Open the page in an Incognito window
This keeps extensions from adding their own tasks to the results.
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.
Record a page load
Click the reload-and-record button and wait until the page settles.
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.
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.
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.
Remove scripts you do not need
Delete old tags, unused widgets and abandoned plugins. Code that never loads costs nothing.
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.
Split big functions and yield
Break loops and setup work into chunks and give the browser a chance to handle input between them.
Code-split large bundles
Load only the code the current page needs. Dynamically import features such as sliders or maps when they are used.
Re-test with 4x CPU slowdown
Record again and compare the number and length of red-marked tasks.
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
}
}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).
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.
Audit installed apps
In Online Store > Themes > Customize, check App embeds and turn off those you do not use. Uninstall apps you have stopped using and remove leftover code in theme.liquid.
Defer theme scripts
In your theme code, add the defer attribute to non-critical script tags in theme.liquid. Test the cart and checkout buttons afterwards.
Find heavy tags
Use Preview mode and compare the Performance recording with the tags that fire on Container Loaded and Page View.
Move tags to later triggers
Fire non-essential tags on Window Loaded or on a timer instead of All Pages at Page View, and pause tags you no longer use.
Trim custom code
Check Project Settings > Custom Code and each page's settings for scripts in the head. Move non-critical ones to the footer.
Limit heavy interactions
Simplify page-load interactions and Lottie animations that run on load.
Reduce tracking and widgets
Review the Tracking Code and custom code sections of the funnel or page. Remove duplicate pixels and chat widgets you do not use.
Keep pages lean
Avoid stacking many embedded elements and custom scripts on a single funnel step.
Remove unused apps and embeds
Open the Wix App Market list for your site and remove apps you do not use. Wix controls much of the base code, so your lever is what you add.
Check custom code
In Settings > Custom Code, set non-critical scripts to load in the body end and only on the pages that need them.
Review code injection
Check Settings > Developer Tools > Code Injection (or Advanced > Code Injection, depending on your version) and move non-critical scripts to the footer.
Remove extra extensions
Disable third-party widgets and embeds you do not need.
Split bundles
Use dynamic import() and your bundler's code splitting so each page loads only what it needs.
Yield in long loops
Use scheduler.yield() with a setTimeout fallback, as shown above, or move heavy work to a Web Worker.
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
- 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
- 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.
Related issues
- PRF-039INP over 200 ms on a CTA or form interactionFix guide
- PRF-041Total Blocking Time high from heavy third-party tagsFix guide
- PRF-042Submit button unresponsive for seconds while JS loads (dead first click)Fix guide
- PRF-044Main thread busy with session-replay scripts (Hotjar, Clarity, FullStory)Fix guide
- PRF-045Too many tag manager tags firing on page loadFix guide
- PRF-046Multiple versions of jQuery or React loadedFix guide