Skip to main content

In Thoughts

Pretext and the Problem I Didn't Know Existed

2 min read

I have been building web and mobile UI for a while now. I thought I had a decent reade on how browsers actually work under the hood. The I came across Pretext last week and found out I’d been wrong about something for years without even knowing to question it.

Every time a browser needs to know how tall a block of text is, it recalculates the layout of the whole page. Every single time. It is been doing since the 90s. Nobody questioned it because there was no other way. You needed a measurement (complex one for me), we asked the DOM, the browser might did its things, and we moved on.

Pretext, built by Cheng Lou, just doesn’t do that. It reads character size straight from the font engine, some skeptical about this since it just use canvas.measureText and works out the layout with math. I am agree, but this getting interesting when I try to dig out. Where it doesn’t need DOM and no reflow, and the library is 15KB. Apparently it ends up being faster than the browser’s native approach.

The performance alone is impressive, but what actually got me was watching what people started making almost immediately after it dropped. Within the same week:

A dragon of the house targaryen is on the browser baby

A 3d castle, rendered with text along it

A fairy conjuring magic through typography

These weren’t polished products. Just people who grabbed the library the same week it came out and went straight to the FUN part.

And that's the real reminder here, a solid engineering foundation combined with the right tools means the gap between "idea" and "working thing" keeps shrinking. The best engineers aren't just getting faster at building; they're spending more time on the part that actually matters.


I build interfaces for a living. I talk about performance and UX regularly. And I genuinely had no idea this was a thing until last week. That's a weird feeling, a reminder that there's still a lot of floor to lift up.

Read next