Fix main thread blocking
Build-pipeline + runtime fixes without breaking the design
- Senior engineers · IST + EST overlap
- NDA on day 1
- 24-hour reply
Tell us what you need fixed
Reply in 24 hours · NDA on day 1 · No spam.
Fix main thread blocking — done properly, by senior engineers
Our frontend engineers fix main thread blocking on pages that paint quickly but ignore taps for their first few seconds, the gap Lighthouse reports as Total Blocking Time. The browser runs JavaScript, style, layout and input handling on one main thread, and any task over 50 ms counts as a long task: input that arrives meanwhile waits until it ends. During load, long tasks usually come from evaluating large bundles, hydrating a whole component tree at once, synchronous third-party tags in the head, and startup code that initializes every feature before the first interaction. Krapton records a load trace in Chrome DevTools, groups long tasks by script and call stack, and separates first-party work from vendor code. Each task then gets the right treatment. Work that must stay on the main thread is split with scheduler.yield, with a setTimeout fallback in browsers that lack it. Low-priority setup runs in requestIdleCallback. CPU-heavy parsing or computation moves to a web worker, often through Comlink. Non-critical scripts load with async, defer or on interaction, and hydration is narrowed to the components that need it. You receive a task-by-task diagnostic, a reviewed PR, before-and-after traces and notes for your team.
What you're seeing
Lighthouse reports 1500ms+ of total blocking time and the page is unresponsive for the first few seconds.
Our approach
We split long tasks with scheduler.yield + idle callbacks, push CPU-heavy work into web workers, and async-load every non-critical script.
Symptoms teams come to us with
- Lighthouse and PageSpeed Insights report high Total Blocking Time alongside “Minimize main-thread work.”
- Buttons and menus ignore taps for a few seconds after the page first appears.
- The DevTools Performance panel shows red-flagged long tasks clustered right after first contentful paint.
- “Reduce JavaScript execution time” lists your main bundle and tag-manager scripts at the top.
- Scrolling and typing feel janky during load, then become smooth once startup work completes.
What we check first
- One large bundle is parsed, compiled and executed in a single task before anything becomes interactive.
- Hydration processes the entire component tree at once, including sections the user cannot see yet.
- Synchronous scripts in the head, such as tag managers and consent tools, block parsing and execution.
- Startup code initializes analytics, chat, carousels and feature flags eagerly instead of on demand.
- CPU-heavy work such as parsing, sorting or encryption runs on the main thread without yielding.
Concrete deliverables, no fluff
Every engagement ends with measurable, documented outcomes — no black-box agency reports.
- Diagnostic report with reproducible steps
- Implementation merged behind a PR you review
- Verified fix across browsers and devices
- Knowledge transfer to your engineering team
What changes after we ship
Long tasks broken into chunks
Unavoidable main-thread work is chunked with scheduler.yield or a fallback, so the browser can process input between chunks instead of waiting for one long task to end.
Heavy computation off the main thread
Parsing, data transformation and other CPU-bound work runs in web workers with typed message contracts, keeping the main thread free for rendering and input.
Script loading ordered by priority
Every script is classified as critical, deferred, idle or on-interaction, and loading attributes or framework script strategies are set to match that classification.
Comparable before-and-after traces
Lighthouse and DevTools traces captured under identical throttling settings show which long tasks were removed, split or moved, task by task, so the change is verifiable.
From brief to shipped fix
A transparent, low-risk process — a senior engineer reads your brief personally, and nothing starts until you approve a written plan and price.
01
Diagnose
A senior engineer reviews your brief, reproduces the issue, and pinpoints the real root cause — not the symptom — before any code is touched.
02
Scoped plan & quote
You get a written plan to fix Main Thread Blocking, a firm timeline, and a fixed quote. Nothing starts until you approve it — no surprise invoices.
03
Ship the fix
We implement on a branch and open a pull request you review, working to your code-review standards on your repo — never a black box.
04
Verify & hand off
We verify on staging and production, share before/after evidence where it applies, and leave you a short hand-off note so the fix sticks.
Situations we handle
News and content sites
Pages loaded with ad, consent and analytics tags that block for seconds on phones. Tags are sequenced after the content becomes usable, and consent tooling loads without blocking the parser.
Single-page apps with heavy startup
React, Vue or Angular apps that initialize stores, routers and every feature module before the first input. Deferring module setup to idle time or first use removes the startup long tasks.
In-browser CSV and file imports
Apps that parse large spreadsheets or CSV files in the browser and freeze while doing it. Parsing moves into a web worker that posts progress messages, so the interface stays usable during the import.
Why teams hand this task to Krapton
Senior engineers only
Your brief is read and handled by a senior engineer — no junior hand-off, no sales-rep filter in between.
Root cause, not a patch
We reproduce and fix the underlying cause, then add a guard so the same class of issue does not quietly return.
Your repo, your standards
Every change lands as a pull request you review, on your repository, following your existing review process.
NDA on day one
Confidentiality and IP are covered before we look at a single line of code. All work stays in your accounts.
Fixed quote up front
You approve a written plan and price before work starts. If scope changes, we re-quote in writing — no surprise invoices.
Proof, where it applies
Performance, SEO and reliability work ships with before/after evidence so the result is measurable, not anecdotal.
Three ways to engage
No retainer required. Pick the model that matches the work — pricing for this task starts from $500, with a fixed quote before anything starts.
Per task
Most popular
One clearly-scoped fix at a fixed price. Best when you know exactly what is broken and want it handled end to end.
- Fixed quote up front
- One PR, reviewed by you
- No retainer required
Hourly
Pay only for the hours worked. Best for diagnostics, audits, or exploratory work where the scope is still emerging.
- Weekly timesheets
- Pay for what you use
- No minimum commitment
Per sprint
A focused 1–2 week sprint when the work is bigger than one fix but smaller than a full project.
- 1–2 week blocks
- Clear sprint goal
- Scale up or stop anytime
Industry-standard stack, no proprietary lock-in
Fix main thread blocking — your questions, answered
How much does it cost to fix Main Thread Blocking?
Pricing starts from $500 and depends on the scope we find during the diagnostic. You get a fixed, written quote before any work begins — most engagements like this run 1–2 weeks.
How long does it take to fix Main Thread Blocking?
Typically 1–2 weeks for a focused engagement. After a short diagnostic we commit to a firm timeline so you know exactly what to expect.
Which changes fix main thread blocking with the least code risk?
Script loading changes, in most cases. Deferring or delaying non-critical third-party and startup scripts often removes large long tasks without touching application logic. Splitting first-party startup work and narrowing hydration comes next. Moving code into web workers comes last, because it requires restructuring and only suits CPU-bound work that does not need DOM access.
Is scheduler.yield supported in every browser?
No, so we always ship a fallback. Chromium-based browsers support scheduler.yield, while support in other engines is newer or absent, so the code feature-detects it and falls back to a setTimeout-based yield. The fallback still breaks up long tasks, but the continuation joins the back of the task queue instead of keeping its priority, which is acceptable for most startup work.
Will web workers help if most blocking comes from third-party scripts?
Usually not directly. Workers run your own code off the main thread, but tag-manager and vendor scripts expect DOM access and run on the main thread. Tools that proxy third-party scripts into a worker, such as Partytown, help in specific cases but break some tags. Removing, delaying or loading those scripts on interaction is the more reliable fix.
Keep exploring
Related tasks and resources to plan your next step with Krapton.
Let's get this off your plate
Send a 60-second brief on Fix Main Thread Blocking and a senior engineer replies within 24 hours with a plan and a fixed quote. NDA on day one, no retainer required.