NeovaGeavanceerd SEO-platform

Werk op de main thread duurt langer dan 2 seconden

In Neova Draait als Lighthouse aanstaat, een instelling: hij gebruikt de Chrome op je Mac.

Regel laatst nagekeken op 17 oktober 2026 · Gids bijgewerkt op 7 juli 2026

De main thread van de browser is tijdens het laden meer dan 2 seconden bezig, dus de pagina reageert laat op invoer. Lighthouse keurt het af boven 4 seconden. Geen enkele zoekmachine legt deze limiet vast; het resultaat in velddata om in de gaten te houden is een INP onder 200 ms.

Wat je zou kunnen doen

Open de uitsplitsing in Lighthouse en verklein daarna eerst de grootste categorie, meestal scriptevaluatie, stijl en layout.

Waarom Neova dit markeert

  • Zolang de main thread bezig is, kan de browser niet reageren op tikken, klikken of typen, dus de pagina voelt bevroren.
  • Lighthouse markeert meer dan 2 seconden werk op de main thread en keurt het af boven 4 seconden.
  • Geen enkele zoekmachine legt deze grens vast; de veldmeting die Google gebruikt is INP, goed bij 200 ms of minder.

Bronnen

De volledige gids

Dit deel is voorlopig in het Engels.

TL;DR

This audit fires when the browser's main thread stays busy for more than four seconds during load, and the culprit is almost always JavaScript being parsed, compiled, and executed. A saturated main thread cannot answer taps or clicks, which is exactly what tanks your Interaction to Next Paint and Total Blocking Time. You fix it by shipping fewer script bytes, breaking bundles into smaller deferred chunks, offloading heavy computation to a web worker, and evicting the third-party junk that hogs the lane.

What This Check Flags

The main thread is a single execution lane, and the browser runs everything through it one job at a time: parsing markup, recalculating styles, laying out boxes, painting pixels, running your JavaScript, and dispatching every click a visitor makes. When one long task grabs that lane and holds it, the tap a user just performed sits in a queue behind unrelated work. Lighthouse breaks the total busy time into buckets so you can see where the seconds went.

Nine times out of ten the dominant bucket is Script Evaluation plus Script Parse/Compile. That is why this audit is really a JavaScript-weight problem wearing a generic name: the engine has to download the script, parse it into an AST, compile it to bytecode, and then run it, all on the same thread that owes the user a response.

A Real Example, and the Fix

Here is the pattern that generates most of the flagged time: a big synchronous chunk of work kicked off during initialization, blocking the thread in one uninterrupted burst.

// Blocks the main thread for hundreds of ms on load
const rows = JSON.parse(hugePayload);       // parse cost
const enriched = rows.map(expensiveTransform); // one long task
renderTable(enriched);

The transform never yields, so the browser cannot slip an event handler in between iterations. The repair is to break the loop into chunks that hand the lane back, or move the whole thing off-thread. Yielding with scheduler.yield() (or a setTimeout(0) fallback) lets a queued click run between batches:

async function processInChunks(rows) {
  const out = [];
  for (let i = 0; i < rows.length; i++) {
    out.push(expensiveTransform(rows[i]));
    if (i % 200 === 0) await scheduler.yield(); // give the thread back
  }
  return out;
}

Genuinely heavy computation (parsing megabyte payloads, image math, crypto) should not chunk on the main thread at all. It belongs in a web worker, where it runs on a separate thread and posts results back when done.

Where the Time Actually Goes

Lighthouse itemizes the main thread by category. Reading this table tells you whether you have a script problem, a rendering problem, or a parsing problem, because the fix for each is different.

Category What Is Happening First Move
Script Evaluation Your JS is executing Ship less, defer, chunk
Script Parse/Compile Engine reading the bundle Code-split, drop dead code
Style & Layout Recalculating geometry Cut layout thrash, batch DOM reads
Rendering / Paint Drawing pixels Simplify effects, promote layers wisely
Parse HTML & CSS Building the DOM/CSSOM Trim markup, split large stylesheets
Garbage Collection Reclaiming memory Reduce allocations in hot loops

How to Detect It

  1. Lighthouse (Chrome DevTools): run the Performance category and open "Minimize main-thread work". It lists each category with its second count under simulated mobile throttling.
  2. PageSpeed Insights: paste the URL to see the same breakdown against real-user field data, so you know whether lab pain matches what visitors feel.
  3. DevTools Performance panel: record a load, then read the flame chart. Long tasks are marked with a red corner; hover one to see whether it is Evaluate Script, Recalculate Style, or Layout.
  4. DevTools Coverage tab: reload with Coverage recording to see what percent of each script is unused. High unused percentages point straight at bundles worth code-splitting.

How to Fix It

Work in this order, because each step shrinks the problem for the next:

  • Send less script. Audit dependencies, drop heavyweight libraries for native APIs or lighter alternatives, and delete unused JavaScript. Fewer bytes means less to parse, compile, and run.
  • Code-split and defer. Break the monolith into route-level chunks and load only what a page needs. Deferring non-critical scripts keeps them from fighting the initial render.
  • Chunk or offload long tasks. Yield inside loops, or push expensive computation to a web worker so the main thread stays free to answer input.
  • Prune third parties. Tag managers, chat widgets, and A/B tools run their own scripts on your thread. Audit each one and cut what does not earn its keep.

For the JavaScript side specifically, our guides on reducing JS execution time and fixing high TBT go deeper on the exact tactics.

FAQ

Is This the Same as Reducing JavaScript Execution Time?

They overlap but are not identical. Execution time is one bucket inside main-thread work; this audit also counts style, layout, paint, parsing, and garbage collection. If your breakdown is dominated by Script Evaluation, the two audits point at the same fix.

Why Does the Report Look Fine on My Laptop but Fails in Lighthouse?

Lighthouse simulates a mid-range phone with CPU throttling. A fast desktop chews through the same script in a fraction of the time, hiding the problem. Trust the throttled numbers, because that is closer to what most visitors experience.

Does Moving Work to a Web Worker Always Help?

It helps when the work is CPU-bound and does not need the DOM, since workers cannot touch the DOM directly. Data crunching, parsing, and math are ideal. Small tasks are not worth the messaging overhead, so measure before you refactor.

How Does This Connect to My Core Web Vitals?

A busy main thread is the mechanical cause behind bad INP and Total Blocking Time. When the thread is stuck on a long task, the handler that should react to a click is blocked, so the page feels dead even though it looks ready.

What Is a "Long Task"?

Any uninterrupted stretch of main-thread work over 50 milliseconds. Everything past that 50 ms threshold counts toward Total Blocking Time, which is why the goal is many short tasks rather than a few long ones.

Vind dit op je eigen site

Neova voert deze check en alle andere bij elke crawl uit en schrijft de oplossing als ticket voor je team.

  • Desktop-app voor Mac, Windows en Linux
  • Alle 696 checks, elk met zijn bron
  • Search Console en Analytics 4, alleen-lezen gekoppeld
  • Tickets naar Jira, Linear en Asana

Download Neova Desktop Free-abonnement, of Solo 14 dagen gratis, zonder kaart.

Alle checks in de categorie Prestaties · Gidsen · Checkbibliotheek

Geschreven door Neova Labs · Terug naar de Checkbibliotheek