Skip to content
IFAI

Open source

Midjourney dev vibe codes an open-source fix for web text layout

Published Reach 43

Midjourney engineer Cheng Lou just launched Pretext, an open-source, 15KB TypeScript library that fixes a persistent web performance bottleneck. Built using AI vibe coding tools like OpenAI's Codex and Anthropic's Claude, it handles multiline text layout entirely in userland. That bypasses costly DOM reflows and lets text wrap around moving objects in real time.

Midjourney dev vibe codes an open-source fix for web text layout
Image: venturebeat.com

Pretext is a lightweight open-source tool that handles multiline text layout and measurement directly in the browser, making real-time, interactive typography buttery smooth.

Midjourney engineer Cheng Lou released it under the MIT License on March 27, 2026. The entire package weighs in at just 15KB with zero dependencies, written in TypeScript. Even cooler, Lou built the library by vibe coding with AI tools like OpenAI's Codex and Anthropic's Claude.

What it does

On the standard web, making text dynamically respond to moving interface elements has always been a performance disaster. Pretext fixes that entirely.

It turns blocks of multiline text into fluid, responsive spaces. Text can dynamically wrap around moving objects on the screen without stuttering, while preserving letter order, word spacing, and line breaks even as you resize your browser window or drag objects through paragraphs.

Developers immediately ran wild with it. One demo features a dragon flying through a block of text, breathing fire that pushes letters aside in real time. Another developer built a mobile reader where you have to hold your phone completely flat, tilt it, and all the letters slide off the edge like marbles.

Someone else even built a web app that plays the movie Project Hail Mary while rendering the underlying book text dynamically on the fly. On a more practical note, developers are already building custom font resizing and letter spacing tools designed for readers with dyslexia.

How it works

To figure out how tall a paragraph is or where a line wraps, web apps usually have to ask the browser's DOM. Standard APIs like getBoundingClientRect and offsetHeight force what is known as layout reflow, essentially making the browser recalculate the entire page geometry.

Pretext bypasses that whole headache by moving multiline text measurement and layout entirely into userland code. It does the math itself instead of forcing the browser engine to stop and redraw the world.

That architectural trick clearly struck a nerve: within 48 hours of launch, Pretext picked up over 14,000 GitHub stars and generated 19 million views on X. The code is available right now on GitHub for anyone to clone and integrate.

Why it matters

If you build frontends, design interactive editorial sites, or work on web canvases and text engines, Pretext is well worth checking out. It turns custom, brittle layout hacks into a clean, drop-in utility.

Some critics complain that early demos make text illegible, but we think that misses the point. The real takeaway is that individual developers using AI coding assistants can now break through thirty-year-old platform bottlenecks without waiting around for slow browser standards committees.

Sources (1)

  1. [1]
    venturebeat.com(opens in a new tab)Originalventurebeat.com

Best of AI, daily