He just crawled through hell to fix the browser…
Cheng Lou, ex-React Core and Midjourney engineer, releases Pretext — a pure-TypeScript library that measures text without triggering browser layout reflows.
- Pretext bypasses browser layout reflow entirely, eliminating the most expensive operation in text-heavy UI rendering.
- Canvas API provides pixel-accurate string width measurements outside the DOM, with zero reflow cost.
- Line-height algorithm was trained iteratively: LLMs wrote line-break logic, tested against real browsers across languages, and iterated for weeks.
- Cheng Lou previously built React Motion, one of the most widely used animation libraries in the React ecosystem.
- Virtual lists of 10,000+ items now feasible without render-then-measure hacks or guessing heights.
-
Pretext API is two calls:
prepare(segments + caches widths) andlayout(returns total height and line count). - Demo app renders video frames as ASCII art by mapping per-character brightness — made possible only because Pretext knows exact character positions without touching the DOM.
2026-04-02 · Watch on YouTube