Pretext
AI-generated summary of reporting by Simon Willison’s Weblog. Read the original for the full story.
Why it matters
Developers can now compute line-wrapped text heights entirely in JavaScript without expensive DOM measurement, unlocking faster dynamic text layouts and effects in browser apps.
Pretext is a free browser library from Cheng Lou, the programmer who created the React animation library react-motion. It answers a tricky question: how tall will a paragraph of text be after the browser wraps it into lines? Normally you have to actually display the text and measure it, which is slow. Pretext instead measures words once using a hidden canvas, then does the line-wrapping math in memory, allowing applications to add live text effects and layouts without lag.
Pretext, an open-source library from former React core developer Cheng Lou, removes a performance bottleneck: measuring wrapped text heights previously required costly rendering to the page's structure. Teams building editors, document tools, or animation-heavy interfaces gain faster text layout with no licensing cost since it is on GitHub. Adoption risk is low, though accuracy was validated only against browser rendering of test documents rather than a formal benchmark. No pricing or support terms are stated.
Pretext (github.com/chenglou/pretext) splits text into segments, handling soft hyphens, non-Latin scripts and emoji, measures each with an off-screen canvas in a one-time prepare() call, caches results, then layout() emulates browser word-wrapping to compute line counts and heights at a given width. Validation rendered the full Great Gatsby across multiple browsers, later extended to Thai, Chinese, Korean, Japanese and Arabic corpora. No specific speedup figures are published in the article.
Read the original
This summary exists to save you time, not to replace the source.
Key terms
Was this summary useful?
One click, anonymous. It tells us which summaries to re-run.
Related reading
Code-driven AI illustrations are more useful than images from dedicated image models
Code-driven AI illustrations let designers edit assets directly in code, saving time on iteration and ensuring consistency, which is a game-changer for teams that need rapid, reusable visual content.
A hierarchical note-taking app for building large personal knowledge bases
Trilium lets users build and navigate massive personal knowledge bases without duplicating content, saving time on organization and retrieval.
Desktop apps in Go with native UI or web frontend
Go developers can now ship cross-platform desktop and mobile apps in a single small binary without cgo or heavy runtimes, cutting build complexity and deployment size.
OpenBitFun: an agent workspace with four harness modes and phone remote control
OpenBitFun lets agents run on any machine and be controlled from a phone, eliminating the need to choose between local power and remote access, saving developers time switching contexts.
Intel One Mono: a monospaced font designed with low-vision developers
Developers with low vision or eye fatigue can read code more clearly, reducing errors and improving productivity.