Why Is the Browser's Main Thread So Expensive? A Deep Dive into Web Performance Bottlenecks

The browser's main thread is an indivisible, scarce resource — all frontend performance optimization is fundamentally about relieving its burden.
This article examines the browser's main thread as the core web performance bottleneck, explaining how it must serially handle HTML parsing, JavaScript execution, style calculation, layout, painting, and user input — blocking any one of these tasks causes jank. The thread's "expense" stems from its indivisibility: it can't be parallelized, and any task over 50ms becomes a Long Task that harms UX. The article connects this to Core Web Vitals (INP, LCP, TBT), offers practical strategies like task splitting, Web Workers, and JS optimization, and elevates the discussion to architecture — explaining why SSR, Islands Architecture, and frameworks like Qwik and Astro are resurging: they all treat minimizing main thread cost as their primary design goal.
The Overlooked Performance Bottleneck: The Browser's Main Thread
In modern web development, we're accustomed to building applications with sophisticated frameworks and rich interactions — yet we often overlook the most fundamental performance constraint: the browser's Main Thread. This single thread is responsible for nearly every critical task: parsing HTML, executing JavaScript, calculating styles, layout, painting, and responding to user input. When it gets blocked, pages stutter, drop frames, or become completely unresponsive.
A recent article titled The Browser's Main Thread Is Expensive, which sparked discussion on Hacker News, brought this topic back to center stage for developers. Its core message cuts straight to the point: the main thread is a scarce and expensive resource, and any operation that occupies it for extended periods directly harms the user experience.

What Does the Browser's Main Thread Actually Do?
A Heavy Burden on a Single Thread
The browser's rendering process fundamentally revolves around the main thread. It must complete the following tasks serially:
- Parsing the DOM and CSSOM
- Executing JavaScript (including virtual DOM diffing, state updates, etc.)
- Style Recalculation
- Layout / Reflow
- Paint and pre-compositing preparation
- Handling user input events (clicks, scrolls, keyboard)
The critical issue is that most of these tasks are synchronous and sequential. When JavaScript runs for a long time, the main thread can't break away to handle user clicks or scrolls — and the browser exhibits what we call "jank." This is why a seemingly simple operation, backed by expensive computation, can render the entire interface unresponsive.
Why Is the Main Thread "Expensive"?
The "expense" of the main thread lies in its indivisibility. A CPU may have multiple cores, but the critical rendering path is essentially confined to a single thread. This means developers can't simply solve the problem by "adding more machines" or "spinning up more threads." Every millisecond of main thread time is a scarce resource. Once a task exceeds 50ms, it's classified as a Long Task and significantly degrades interaction responsiveness.
The Connection Between Main Thread Blocking and Core Web Vitals
The Design Logic Behind Performance Metrics
Understanding the cost of the main thread helps clarify the rationale behind Google's Core Web Vitals:
- INP (Interaction to Next Paint): Measures interaction responsiveness and is directly affected by main thread blocking. If the main thread is busy, user feedback after a click will be delayed.
- LCP (Largest Contentful Paint): Heavy JavaScript execution delays the rendering of critical content, pushing LCP higher.
- TBT (Total Blocking Time): Essentially the cumulative time the main thread is occupied by long tasks.
The design logic of these metrics all centers on one core question: can the main thread respond in time? Web performance optimization, in large part, is fundamentally about offloading the main thread.
Practical Strategies for Relieving Main Thread Pressure
Break Up Long Tasks to Improve Responsiveness
The most direct strategy is to split long tasks into smaller chunks and yield control of the main thread between them. Modern browsers offer APIs like scheduler.yield(), or you can use the classic setTimeout and requestIdleCallback to implement task scheduling — giving the browser opportunities to handle user input in between.
Use Web Workers to Offload Computation
For purely computational tasks (such as data processing, encryption, or image analysis), migrate them to Web Workers. Workers run on a separate thread and don't block the main thread. While Workers can't directly manipulate the DOM, they are a powerful tool for freeing the main thread across the vast majority of background computation scenarios.
Reduce Unnecessary Rendering Overhead
Framework-level optimizations are equally critical. Avoiding unnecessary component re-renders, using memoization judiciously, and minimizing large-scale DOM operations all effectively reduce the cost of style recalculation and layout. Additionally, using CSS contain and content-visibility properties helps the browser narrow the scope of reflows and repaints.
Optimize JavaScript Bundle Size and Execution Efficiency
Techniques like Code Splitting, lazy loading, and Tree Shaking reduce the amount of JS that needs to be parsed and executed on initial load. Keep in mind that parsing and compiling JavaScript itself consumes main thread time — every byte of JS has a cost.
Architectural Thinking: From Client-Side Rendering to Main-Thread-Friendly Design
The discussion sparked by this article goes beyond technical tricks and touches on the philosophy of front-end architecture. As we increasingly push rendering logic to the client, we're effectively transferring costs to the main thread of the user's device.
This explains why Server-Side Rendering (SSR) and the Islands Architecture have made a comeback in recent years. Their core idea is to minimize the JavaScript shipped to the client that needs to execute on the main thread. Frameworks like Astro and Qwik treat "main thread cost" as a primary design constraint — using "zero JS by default" or Resumability to minimize client-side computational overhead.
Closing Thoughts: Developing a Main Thread Budget Mindset
The high cost of the browser's main thread is an easily overlooked yet critically important performance truth. It reminds us that the essence of web performance optimization isn't about chasing flashier features — it's about respecting the limits of this scarce resource.
For developers, cultivating a "main thread budget" mindset is essential. When writing any code that might block the main thread, always ask yourself: does this task truly have to run on the main thread? Can it be broken up, deferred, or offloaded? Only by asking these questions can we build web applications that are genuinely smooth and responsive.
Related articles

Insufficient Source Material to Generate a Valid Article
The provided source material is a single unrelated tweet with no AI or tech relevance — insufficient to support a complete, valid technical article.

Insufficient Source Material to Generate a Valid AI/Tech Article
This source material is a tweet about the ages of Underworld members — unrelated to AI or tech, and insufficient to support a full article.

Insufficient Material: Unable to Generate a Valid AI/Tech Article
The provided material is a condolence tweet about a San Diego mosque attack — unrelated to AI/tech and too limited to generate a valid technical article.