Pretext: The Text Layout Library That Changes Everything
Cheng Lou just solved a 30-year-old web problem: measuring multiline text height without touching the DOM. Pretext is 15KB, zero-dependency TypeScript — and it changes what interfaces can actually do.
Cheng Lou launched Pretext on March 27, 2026. In 48 hours: 14,000 GitHub stars, 19 million views on X. This isn't another hype cycle. It's infrastructure.
The problem nobody wanted to solve
There's something the web hasn't been able to do for 30 years. Calculate the height of a multiline text block — without rendering it into the DOM.
That sounds absurd. But that's how it is. The moment you need to know the height of text before displaying it, you have to trigger a layout reflow: the browser recalculates the entire page geometry. It's one of the most expensive operations in existence. That's why virtualized lists (Twitter, Slack) are so complex to build. That's why a responsive dynamic magazine layout on the web stays a Figma mockup rather than a shipping reality.
Pretext bypasses this. Completely.

What Pretext actually does
The library is pure TypeScript, 15KB, zero dependencies. It measures text via an offscreen canvas, caches the results, and exposes two functions: prepare() and layout(). prepare() is expensive — once. Then layout() is pure arithmetic. No DOM. No reflow.
Result: a single layout operation on 500 text blocks takes approximately 0.09 milliseconds — up to 600 times faster than traditional DOM-based methods. Fast enough to run at 120fps, even when the user is resizing the window and every block needs to recalculate its height in real time.
The demos show what this unlocks concretely: masonry of hundreds of thousands of blocks, shrinkwrapped chat bubbles, responsive multicolumn magazine layout, variable-font ASCII art. This isn't a graphics rendering demo. It's page layout, solved properly, for the first time.

How it was built — and why that's interesting
The library was built using an AI-assisted iterative method. By providing Claude Code and Codex with actual browser rendering as ground truth and having them measure and iterate against those results at every significant container width — running over weeks — Lou achieved pixel-perfect accuracy without WebAssembly binaries or font-parsing libraries.
What interests me there isn't the technical feat. It's the method. He used AI to solve a correspondence problem: making pure TypeScript calculations produce exactly the same results as Chrome, Safari, and Firefox — with all their respective quirks. Weeks of automated iteration against text corpora in Arabic, Korean, Japanese, Thai. The entire Great Gatsby to validate metrics.
That's a different way to think about what a tool can do. Not generation. Calibration.
What this changes for us as designers
The boundary between what we can do in Figma and what we can actually ship in the browser just moved.
For years, print designers could do text wrapping around images, dynamic multicolumn layout, pixel-precise typography — because print rendering engines calculated all of that. We did CSS, compromises, and static exports that didn't reflect what we actually wanted.
There has always been a gap between what print designers can do and what web designers are allowed to do. It mostly comes down to text. Pretext doesn't close that gap in a day. But it lays a foundation nobody had laid properly before.
What it unlocks directly: AI interfaces with truly tight chat bubbles without jank. Infinite lists without the usual virtualization complexity. Editorial layouts that actually respond to content rather than a fixed grid. Canvas or WebGL experiences where text behaves like a fluid.

What I actually think
Cheng Lou described having "crawled through depths of hell" to develop this library and called it a fundamental shift in web development. That's not launch-day hyperbole. It's someone who solved a problem the frontend community had been avoiding for decades because it was too ungrateful.
The question now is: what do we do with it?
The first community demos are dragons swimming through letters and Tetris games in ASCII. That's normal — that's what people do when a constraint disappears. They test limits. The next step is the serious applications: rich text editors, dynamic feeds, AI interfaces, editorial sites that deserve better than approximate CSS layout.
Pretext won't become the standard overnight. It requires relearning to think about layout without CSS as a safety net. But the fact that it's MIT, pure TypeScript, 15KB with no dependencies — that's exactly the shape foundational infrastructure should take.
I'm going to integrate it into my prototyping workflow. And I think in 18 months, some of the most interesting interfaces on the web will be built on top of it.
You have a project that needs an interface that actually does something interesting?
Let's talk