<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/the-browser-s-main-thread-is-expensive-2bvhrzwda" -->

---
title: The Browser's Main Thread Is Expensive | daily.dev
description: Deep-dive into why the browser's main thread is a scarce, single resource shared by JavaScript execution and rendering, and how that causes jank, stutter, and...
canonical: https://daily.dev/posts/the-browser-s-main-thread-is-expensive-2bvhrzwda
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: The Browser's Main Thread Is Expensive | daily.dev
og:description: Deep-dive into why the browser's main thread is a scarce, single resource shared by JavaScript execution and rendering, and how that causes jank, stutter, and...
og:url: https://daily.dev/posts/the-browser-s-main-thread-is-expensive-2bvhrzwda
og:image: https://api.daily.dev/og/posts/2bVHRZwDA.png
og:image:alt: The Browser's Main Thread Is Expensive
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# The Browser's Main Thread Is Expensive

**[Lobsters](https://daily.dev/sources/lobsters)** · 32 min read · 1 upvotes · 1 comments

## Summary

Deep-dive into why the browser's main thread is a scarce, single resource shared by JavaScript execution and rendering, and how that causes jank, stutter, and delayed input on interaction-heavy screens. Covers two families of mitigation: using the main thread wisely (splitting long tasks with setTimeout/rAF/scheduler.yield, batching frequent events with debounce/throttle/rAF, prioritizing urgent work with custom queues, and deferring work with code splitting and IntersectionObserver) and avoiding the main thread altogether (compositor-only animations via transform/opacity, the FLIP technique for layout animations, offloading heavy computation to web workers with transferable objects, and eliminating work via dropping/merging/memoization). Includes interactive demos illustrating each technique with a live-chat flood, particle simulation, markdown preview, photo queue, infinite feed, and seam-carving image processing.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://kciter.so/posts/the-expensive-main-thread/en>

## Questions this post answers

### Why does a CSS animation using transform keep running smoothly even when JavaScript blocks the main thread?

Because transform and opacity animations are handled by the compositor thread rather than the main thread. These properties move an already-painted layer or adjust its transparency without requiring layout or paint recalculation, so the browser can animate them directly on the compositor thread even while the main thread is busy running JavaScript.

_daily.dev surfaces performance techniques like compositor-driven animations for developers chasing smoother UIs._

### What is the FLIP technique for animating list reordering without triggering layout on every frame?

FLIP stands for First, Last, Invert, Play: measure the element's position before the move (First), let the layout change happen once and measure the new position (Last), apply a transform so it visually appears in its old spot (Invert), then animate that transform away (Play). Only one layout recalculation occurs, and the rest of the animation runs on the compositor via transform, keeping it smooth even under main-thread load. Vue's TransitionGroup and Framer Motion's layout animations use this under the hood.

_Developers building list-reorder animations can lean on daily.dev to track techniques like FLIP before shipping._

### When does it make sense to offload work to a web worker versus keeping it on the main thread?

Web workers are worth using when computation is heavy enough to outweigh the communication cost and doesn't require DOM access, since workers can't touch the screen directly and communicate with the main thread only via postMessage, which serializes data. For large data like pixel buffers, using transferable objects such as ArrayBuffer moves data by reference instead of copying, keeping the transfer cost near zero regardless of size.

_daily.dev helps developers weigh worker-offloading trade-offs before restructuring heavy computation._

## Community take

How the wider developer community reacted, aggregated from 2 discussions and 272 comments across lobsters, hackernews (as of 2026-09-14).

**TL;DR:** Most commenters praise the article's writing and interactive demos, but a large side-debate argues that main-thread scheduling is a secondary concern compared to bloated JS bundles, heavy hydration, and slow devices/connections; there's also a notable dispute over whether the writing itself is AI-generated.

**Sentiment:** 45% positive · 35% mixed · 20% skeptical

**The case for**

- Many found the interactive demos and explanations exceptionally well crafted and clear.
- Some appreciated learning specific techniques or facts they hadn't known before, like ArrayBuffer transfer semantics or React's use of MessageChannel to yield.
- Several defended the article's usefulness for genuinely interactive apps like editors, games, or streaming chat UIs.

**The pushback**

- Multiple commenters argued that bundle size and hydration cost dwarf main-thread scheduling as the real cause of slow sites, especially on weak connections or low-end hardware.
- A recurring accusation that the article was AI-written or AI-translated slop, prompting significant pushback from others who found it well-written.
- Some felt most websites don't need heavy client-side interactivity at all and should just use plain HTML/CSS instead of SPA frameworks.
- A tangent criticized virtualized/infinite-scroll feeds for breaking browser search functionality.

**By community**

- lobsters (mixed): Very light engagement, with one nitpick about framing the main thread as 'expensive' rather than resource-constrained, and one brief positive remark.
- hackernews (heated): Praise for the article's quality and demos coexists with a large, contentious debate over whether bundle size/hydration matters more than main-thread scheduling, plus a separate flare-up over alleged AI-generated writing.

**Hottest debate:** Whether the real cause of slow sites is main-thread scheduling as covered in the article, or bloated JS bundles and hydration overhead that no amount of yielding can fix.

**Open questions**

- Is there a good technical solution for server-rendered pages that need to upgrade to interactive client-side experiences?
- How should teams balance bundle-size reduction versus main-thread scheduling techniques given limited engineering time?

**Highlights**

> Good article and I wish this was much better known. The issue is though that it's too focused on interactivity. In reality, 90%++ of slow sites are not slow because of interactivity really, they are slow because they ship enormous react/nextjs bundles and have extremely heavy hydration work to do. _so many_ sites have bundles >10MB that need to be downloaded, parsed and hydrated. I've even seen (many) sites which have multiple SPAs stacked inside of them. If you're on a slow internet connection and/or CPU the page is basically unusable for many tens of seconds and no amount of yielding post bundle hydrate will really solve that.
> — [martinald on hackernews · 6 comments](https://news.ycombinator.com/item?id=49548745)

> I'm not sure the author realises _what_ a massive impact bundle size has on the main thread though, especially hydration. The majority of apps I've optimised over the years have the (often vast) majority of main thread time spent on the bundle parse/hydration (plus obviously network). Also, removing dependencies is not easy. I've seen many corporate that have a huge UI lib for example that everyone should use for brand consistency. But it's many MBs of JS, because it has to cover every possible use case. This doesn't even get into 3rd party vendors who _also_ ship react et al and have other bundles. I'm not saying the article is wrong, but if you want to free main thread time especially at the most critical point (when the user has initially loaded the page) you _probably_ will find that most of the opp is in bundle size and hydration improvements.
> — [martinald on hackernews · 2 comments](https://news.ycombinator.com/item?id=49552837)

> "and there’s a reason for that" "The code isn’t slow. It just happens to be the code that’s holding the main thread." "dealing with the main thread becomes the important part" "What to remember for now is that holding the main thread for a long time is the same thing as freezing the screen." "One thing not to misread here is" I realize the author may not write native English, but this is not translation slop, it's AI writing slop.
> — [Lebenita on hackernews · 2 comments](https://news.ycombinator.com/item?id=49548516)

> I want to do a blanket response to people calling this AI slop: the post was written in korean and translated to english. Calling this slop is judgment slop.
> — [prodigycorp on hackernews · 1 comments](https://news.ycombinator.com/item?id=49548574)

> > So what if off-screen posts were left as empty shells that only take up their height, and got filled with real content as they approach the screen? Yeah fuck everyone doing that, hello Reddit, Outlook for Web or Bluesky. It makes searching on such "feed" pages with the browser's search function an utter pain in the ass, made worse by the fact that the platforms' own search functions are outright braindead.
> — [mschuster91 on hackernews · 1 comments](https://news.ycombinator.com/item?id=49548104)

> > The browser’s main thread is expensive The main thread is not expensive, it just comes with real-time constraints (if you target certain frame rates and maximum input lag). Saying it's "expensive" really doesn't capture the essence at all.
> — [BenjaminRi on lobsters · 1 points](https://lobste.rs/s/zatuk4/browser_s_main_thread_is_expensive#c_mzkslp)

**Source threads**

- [lobsters](https://lobste.rs/s/zatuk4/browser_s_main_thread_is_expensive) · 7 points · 2 comments
- [hackernews](https://news.ycombinator.com/item?id=49522137) · 384 points · 270 comments

## Community discussion

Top comments from developers on daily.dev.

**@rizzdev** · 0 upvotes

> The spoiler is the thing people always reach for: the code isn't slow, it's just holding the main thread. Yielding doesn't make it faster, it just stops it from blocking everything else while it runs. The rAF-based split by time is the right call here, by the way — setTimeout drifts and requestAnimationFrame stays synced to the refresh cycle

## Similar posts on daily.dev

- [Medium](https://daily.dev/posts/medium-w2o7cicnw) · Medium · 0 upvotes · 0 comments
- [Rendering Is a Browser Decision, Not a JavaScript One](https://daily.dev/posts/rendering-is-a-browser-decision-not-a-javascript-one-ukimtnhiq) · Code Like A Girl · 3 upvotes · 0 comments
- [Web Workers: A Second Thread for Your JavaScript](https://daily.dev/posts/web-workers-a-second-thread-for-your-javascript-cqdypees4) · FREEK.DEV · 0 upvotes · 0 comments
- [JavaScript Event Loop Explained: Queue Tracing and Debugging Guide](https://daily.dev/posts/javascript-event-loop-explained-queue-tracing-and-debugging-guide-sa0thbcrm) · SitePoint · 150 upvotes · 4 comments

---

Tags: [#webdev](https://daily.dev/tags/webdev), [#javascript](https://daily.dev/tags/javascript)

[View this post on daily.dev](https://daily.dev/posts/the-browser-s-main-thread-is-expensive-2bvhrzwda)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"The Browser's Main Thread Is Expensive","url":"https://daily.dev/posts/the-browser-s-main-thread-is-expensive-2bvhrzwda","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/the-browser-s-main-thread-is-expensive-2bvhrzwda"},"datePublished":"2026-09-04T04:11:16.170Z","dateModified":"2026-09-14T06:33:50.636Z","description":"Deep-dive into why the browser's main thread is a scarce, single resource shared by JavaScript execution and rendering, and how that causes jank, stutter, and...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/37bf0c2a6354fdb032948a30d18cfb21?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/37bf0c2a6354fdb032948a30d18cfb21?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Lobsters","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Lobsters","logo":"https://media.daily.dev/image/upload/s--tl8v_Fku--/f_auto,t_logo/v1698841318/logos/lobste.jpg","url":"https://daily.dev/sources/lobsters"},"commentCount":1,"discussionUrl":"https://daily.dev/posts/the-browser-s-main-thread-is-expensive-2bvhrzwda","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":1},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":1}],"keywords":"webdev,javascript","timeRequired":"PT32M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Lobsters","item":"https://daily.dev/sources/lobsters"},{"@type":"ListItem","position":3,"name":"The Browser's Main Thread Is Expensive"}]}
{"@context":"https://schema.org","@type":"WebPage","@id":"https://daily.dev/posts/the-browser-s-main-thread-is-expensive-2bvhrzwda","comment":[{"@type":"Comment","text":"The spoiler is the thing people always reach for: the code isn’t slow, it’s just holding the main thread. Yielding doesn’t make it faster, it just stops it from blocking everything else while it runs. The rAF-based split by time is the right call here, by the way — setTimeout drifts and requestAnimationFrame stays synced to the refresh cycle","datePublished":"2026-09-04T11:08:33.445Z","url":"https://daily.dev/posts/2bVHRZwDA#c-iYhCy8GkA","author":{"@type":"Person","name":"Andrew","url":"https://daily.dev/rizzdev","image":"https://media.daily.dev/image/upload/s--35vRfXAA--/f_auto/v1785413727/avatars/avatar_fQ7ttCKtPuu6tDvcgQXv5?_a=BAMAMicg0"}}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/the-browser-s-main-thread-is-expensive-2bvhrzwda#faq","mainEntity":[{"@type":"Question","name":"Why does a CSS animation using transform keep running smoothly even when JavaScript blocks the main thread?","acceptedAnswer":{"@type":"Answer","text":"Because transform and opacity animations are handled by the compositor thread rather than the main thread. These properties move an already-painted layer or adjust its transparency without requiring layout or paint recalculation, so the browser can animate them directly on the compositor thread even while the main thread is busy running JavaScript. daily.dev surfaces performance techniques like compositor-driven animations for developers chasing smoother UIs."}},{"@type":"Question","name":"What is the FLIP technique for animating list reordering without triggering layout on every frame?","acceptedAnswer":{"@type":"Answer","text":"FLIP stands for First, Last, Invert, Play: measure the element's position before the move (First), let the layout change happen once and measure the new position (Last), apply a transform so it visually appears in its old spot (Invert), then animate that transform away (Play). Only one layout recalculation occurs, and the rest of the animation runs on the compositor via transform, keeping it smooth even under main-thread load. Vue's TransitionGroup and Framer Motion's layout animations use this under the hood. Developers building list-reorder animations can lean on daily.dev to track techniques like FLIP before shipping."}},{"@type":"Question","name":"When does it make sense to offload work to a web worker versus keeping it on the main thread?","acceptedAnswer":{"@type":"Answer","text":"Web workers are worth using when computation is heavy enough to outweigh the communication cost and doesn't require DOM access, since workers can't touch the screen directly and communicate with the main thread only via postMessage, which serializes data. For large data like pixel buffers, using transferable objects such as ArrayBuffer moves data by reference instead of copying, keeping the transfer cost near zero regardless of size. daily.dev helps developers weigh worker-offloading trade-offs before restructuring heavy computation."}}]}
```

