Newsletter
Join the Community
Subscribe to our newsletter for the latest news and updates
Pretext.js is a pure JavaScript text layout engine — 600× faster than DOM measurement. Zero dependencies, framework-agnostic, MIT-licensed.
pretextjs.dev (powered by turbo0)
pretextjs.dev (powered by turbo0)
Submit your own product to reach creators and founders looking for the next tool to try.

Track calories and macros for Qdoba menu items with this interactive nutrition calculator.

SaaSkit is the complete Next.js SaaS boilerplate with authentication, payments, database, RBAC, SEO, analytics, and more. Skip setup and ship faster.
Pretext.js is the official website for Pretext, a pure JavaScript/TypeScript text measurement and
layout engine created by Cheng Lou (chenglou), a former React core team member now at Midjourney.
The library solves a 30-year browser bottleneck: to know how tall a block of text will be,
developers have always had to render it in the DOM and ask the browser — a process that forces
expensive synchronous layout reflow.
Pretext eliminates this entirely with a two-phase architecture. The prepare() function measures
text once via Canvas and Intl.Segmenter, then the layout() function computes line breaks and
heights using pure arithmetic in ~0.0002ms — roughly 600× faster than traditional DOM measurement.
No reflow, no thrashing, no dependencies.
The website features an interactive playground where developers can experiment with Pretext in real
time, live examples demonstrating virtual scrolling, chat bubbles, multilingual content, and
accordion animations, and comprehensive documentation of the library's API. Pretext supports 12+
writing systems including CJK, Arabic, Hebrew, Thai, and mixed bidirectional text.
Pretext.js is MIT-licensed, weighs approximately 15KB, and works with any framework — React, Vue,
Svelte, or vanilla JavaScript. It is used in production at Midjourney to handle real-time AI text
streaming without layout shift.