---
title: "Three ways to compile React. One table to compare them."
description: "React Compiler, Million.js, and Farm.js's compiler on one keyed table, with the same React, the same browser, and a correctness check before any timing."
---


# Three ways to compile React. One table to compare them.

KinfeMichael Tariku · Dec 2026

There are three ideas for making React do less work, and each one comes with a compiler.

- **React Compiler** memoizes. It rewrites components so React can skip rendering the parts whose inputs didn't change.
- **Million.js** turns a component into a block. An update compares the block's dynamic values instead of a tree of elements.
- **Farm.js's compiler** takes over the keyed lists it can prove are safe. After mount, an update finds rows by key and patches DOM it prepared at build time, without running the component again.

I built one table four ways and timed every action in Chrome.

**On a keyed list, the list is the work. React Compiler and Million's automatic mode leave the list to React's reconciler, so they ran this table at React's speed. Farm.js's compiler takes the list off the reconciler, and a full cycle of seven actions took 170 ms of main-thread time against 293 to 302 ms for the other three.**

That's one table, not your app, and Farm.js isn't free: it ships more JavaScript, it barely speeds up the first render, and it leaves [some row shapes](/docs/renderers/react#compiled-keyed-rows-and-react-list-boundaries) to React. The rest of this post is how I measured it and what each compiler skips.

<span id="one-table-four-builds" className="blog-heading-anchor" />

## One table, four builds

One component, `Bench`, holds 1,000 keyed rows and a selected index. Seven buttons create the rows, update every tenth label, select the next row, swap rows 2 and 999, append 100, remove every tenth, and clear. It's modeled on js-framework-benchmark, with a text input in every row so the check below can test an input's value and focus:

```tsx
// src/bench.tsx (the list)
<div id="rows">
  {rows.map((row, index) => (
    <div
      className={index === selected % 1_000 ? "row selected" : "row"}
      data-row-id={row.id}
      key={row.id}
    >
      <span>{row.id}</span>
      <strong>{row.label}</strong>
      <input aria-label={`Draft for row ${row.id}`} />
    </div>
  ))}
</div>
```

Every build compiles that same file in a Vite 8.3.4 production build with React 19.2.8, and runs in Chrome 158:

| Build              | What it adds                                                                                                          |
| ------------------ | --------------------------------------------------------------------------------------------------------------------- |
| React              | Nothing.                                                                                                              |
| React Compiler 1.0 | `babel-plugin-react-compiler` in `@vitejs/plugin-react`, default options.                                             |
| Million.js 3.1.11  | `million.vite({ auto: { threshold: 0 } })`, so automatic mode compiles everything it can.                             |
| Farm.js            | Farm.js's compiler through the `@farm.js/react` Vite plugin, the same transform `react({ compiler: true })` turns on. |

Before any timing, each build has to pass the same check in the browser: the right rows, labels, and selection, the swap in the right order, the same DOM node for every row that survives, and an input that keeps its value, focus, and cursor selection. Each build also has to prove its compiler ran. React Compiler's output must import its memo cache, Million's must contain a compiled block, and Farm.js's must use its keyed-rows block. A build that fails the browser check isn't timed, and a missing proof stops the run.

<span id="how-i-timed-it" className="blog-heading-anchor" />

## How I timed it

The benchmark records a Chrome trace. For each click it adds up every main-thread task from the click to the next click, with a painted frame in between: the update, the DOM writes, style, layout, paint, and garbage collection. That's the time a person waits. Where I split out style, layout, and paint below, I mean all six of Chrome's rendering events: style recalculation, layout, pre-paint, paint, layerize, and commit.

Three things gave wrong answers before that.

- **Our own proof.** Since November, Farm.js's compiler leaves rows with `defaultValue` to React, because its row runtime lost the value on appended rows ([#2476](https://github.com/farming-labs/farm.js/pull/2476)). The table's input had a `defaultValue`. Anyone who ran the benchmark after that measured React's list under Farm.js's name, and the proof still passed: it searched the whole bundle for a string that unrelated runtime code also contains. The proof now reads the compiled module, and the input has no default value. Every build gets the same input.
- **Stopping at the first DOM write.** The old harness stopped its clock at the first change a `MutationObserver` saw. In that fallback build, Farm.js updated the row count in the click's task and React rendered the rows a task later, so the harness reported 1,000 rows created in 0.4 ms. They weren't.
- **Chrome's script counter.** `Performance.getMetrics` leaves script that runs in promise reactions out of `ScriptDuration`. Farm.js's compiled updates flush in a promise reaction, so that counter undercounts Farm.js.

<span id="the-numbers" className="blog-heading-anchor" />

## The numbers

Milliseconds of main-thread time from click to painted frame, the median of 100 clicks per action (5 trials of 20 cycles, build order rotated each trial). Million.js is its automatic mode:

| Action            |     React | React Compiler | Million.js |   Farm.js |
| ----------------- | --------: | -------------: | ---------: | --------: |
| Create 1,000 rows |      87.0 |           86.1 |       86.4 |      80.8 |
| Update every 10th |      20.8 |           21.1 |       20.5 |      14.9 |
| Select a row      |      14.5 |           14.4 |       14.2 |       8.9 |
| Swap two rows     |      86.8 |           86.5 |       86.2 |      11.4 |
| Append 100 rows   |      27.7 |           27.4 |       27.5 |      18.5 |
| Remove every 10th |      29.0 |           28.5 |       28.5 |      22.6 |
| Clear             |      15.8 |           14.2 |       16.9 |       9.3 |
| **Full cycle**    | **301.7** |      **296.9** |  **292.8** | **170.5** |

Less is better. I ran the whole benchmark twice, back to back. Farm.js's ratio to React moved by at most 4% on any action between the two runs, and each build's full cycle by at most 3%.

The machine was busy: an M1 with a load average between 54 and 185 while the runs ran. The absolute numbers are higher than a quiet laptop would show. Every build ran on the same machine in the same runs, so the comparison holds; the milliseconds don't transfer to your laptop.

Bytes and memory, from the same builds:

| Build           | JavaScript, gzip | JS heap after GC |
| --------------- | ---------------: | ---------------: |
| React           |         59.4 KiB |          3.3 MiB |
| React Compiler  |         60.0 KiB |          3.3 MiB |
| Million.js auto |         66.3 KiB |          3.5 MiB |
| Farm.js         |         74.1 KiB |          2.4 MiB |

<span id="what-each-compiler-skips" className="blog-heading-anchor" />

## What each compiler skips

I counted each build's DOM writes for the swap and the select:

| Build           | Swap: rows reinserted | Select: attribute writes |
| --------------- | --------------------: | -----------------------: |
| React           |                   997 |                    2,002 |
| React Compiler  |                   997 |                    2,002 |
| Million.js auto |                   997 |                    2,002 |
| Farm.js         |                     2 |                        2 |

The three builds that leave the list to React make the same writes, because React makes them.

**React** re-renders `Bench`, builds 1,000 new row elements, and diffs them against the old ones by key. The diff walks the new order from the top. Row 999 now comes second, so every row after it that used to sit before it counts as moved: React reinserts 997 rows to swap two. Most of the swap's time isn't React's: 57.4 of its 86.8 ms went to style, layout, and paint for the rows it moved. Selecting a row writes 2 class changes and 2,000 attribute writes that change nothing. React DOM sets and then removes `name` on each input whose row re-rendered.

**React Compiler** doesn't change that. It memoizes, and every row here reads `rows` and `selected`, so each update rebuilds all 1,000 row elements and React diffs them as before. It pays off when rows are their own components with inputs that didn't change. This table has no row component, so there's nothing for it to skip.

**Million's automatic mode** compiles the component's stable shell into a block and leaves `rows.map(...)` to React as a portal. The list, which is the work, still goes through React's diff.

**Farm.js's compiler** turns the `map` into a keyed-rows block. React still renders the first 1,000 rows. After mount, Farm.js adopts them, and later updates don't run `Bench` or the map callback. A swap compares the new keys with the old order position by position, sees two rows trade places, and moves those two. Selecting a row writes the two classes that changed. Its swap spent 8.1 ms in style, layout, and paint, because the browser only had two rows to place.

Million's docs recommend `<For>` for lists, so I built that too. It failed the identity check: after the swap, rows 2 and 999 were no longer their own DOM nodes, and after "remove every 10th", a value set in one row's input showed up in the next row. `<For>` reuses rows by position, not by key. `<For>` with a `block()` row threw `f is not a function` on its first render under React 19. Million's last release was June 2024, six months before React 19, so I report both and time neither.

<span id="an-independent-check" className="blog-heading-anchor" />

## An independent check

My table is mine. [js-framework-benchmark](https://krausest.github.io/js-framework-benchmark/current.html) is not: every entry is written by people who know that framework, with the row components and memoization it likes. On its official Chrome 158 results, keyed, where 1 would be the fastest at every operation:

| Entry          | Score |
| -------------- | ----: |
| Vanilla JS     | 1.033 |
| Farm.js React  | 1.125 |
| Solid 1.9      | 1.133 |
| React 19.2     | 1.555 |
| React Compiler | 1.601 |

The React Compiler entry uses a `Row` component, which is the shape React Compiler wants, and it still lands next to plain React. Million has no entry in its keyed results today.

<span id="try-it" className="blog-heading-anchor" />

## Try it

Turn the compiler on with a report:

```ts
// farm.config.ts
import { defineConfig } from "@farm.js/core";
import { react } from "@farm.js/react";

export default defineConfig({
  renderer: react({ compiler: { report: true } }),
});
```

Run `farm build` and open `.farm/react-compiler.json`. It lists every component the compiler took and the reason for every one it left to React.

Run the table yourself:

```bash
cd benchmarks/react-optimizer
npm install
BENCH_BROWSER_CHANNEL=chrome npm run bench
```

[React compiler docs](/docs/renderers/react#aot-compiler) · [The benchmark](https://github.com/farming-labs/farm.js/tree/main/benchmarks/react-optimizer) · [js-framework-benchmark](https://krausest.github.io/js-framework-benchmark/current.html)

A compiler can only skip work it can prove is unnecessary. On a keyed list, the proof is about rows, not renders.
