A new GitHub repo just mass-solved a 30-year-old bottleneck in web development. The library is called Pretext. Built by Cheng Lou — React core team alum, creator of react-motion, now engineering at Midjourney. It crossed 14,000 stars in 48 hours and is sitting at 34k+ as I write this. The problem it solves: text measurement. To dynamically wrap text or calculate its height, the browser has to render it and measure the DOM. This triggers layout reflow — the single most expensive operation in the browser. If you're building dense data tools, virtualized lists, or real-time AI interfaces, this constant recalculation destroys your framerate. Lou's solution: bypass the DOM entirely. Pretext uses the browser's off-screen Canvas font engine to measure text segments once, then pure JavaScript arithmetic handles every subsequent layout calculation. No DOM reads. No reflow. Just math. The result: ~500x faster. Layout drops from milliseconds to microseconds. 120fps text wrapping around moving shapes. Perfectly shrink-wrapped chat bubbles — something CSS literally cannot do natively. Here's what caught my attention as someone building ML systems daily: The hardest part wasn't the math — it was handling edge cases across every script (Arabic, Korean, Thai, emoji clusters). Lou pointed Claude Code and Codex at the browser's actual layout outputs and had the AI iterate against that ground truth across massive multilingual corpora for weeks until pixel-perfect accuracy was achieved. This is what high-leverage AI-assisted engineering actually looks like. Not generating boilerplate. Using AI to systematically converge on correctness against a complex, measurable standard. With layout finally decoupled from the DOM, the web is ready to compete with native for complex, real-time UIs — especially the kind AI agents will need to generate dynamically. Have you tested Pretext in your stack yet? What's your first use case? #SoftwareEngineering #WebDevelopment #JavaScript #ArtificialIntelligence #MachineLearning #OpenSource #FrontendDev
This is brilliant. That's exactly how we should lavarge AI
Here is the link to Cheng Lou's actual repository if you want to dig into the code: https://github.com/chenglou/pretext