Pretext
Fast JavaScript text measurement and multiline layout without DOM reflow
Pretext is a pure JavaScript and TypeScript library by Cheng Lou for multiline text measurement and layout. It avoids DOM measurement calls such as getBoundingClientRect, which force layout reflow. It uses the browser font engine as ground truth and renders to the DOM, Canvas, or SVG. It supports many writing systems and has more than 50,000 GitHub stars.
npm install @chenglou/pretextUse it for virtualized lists, canvas text, or any layout that must know text height before render. Check the license file, because GitHub does not detect a standard license.
Why it is here. It removes a classic performance cost in text-heavy interfaces.
- No DOM reflow
- DOM
- Canvas
- and SVG output
- 50
- 000+ GitHub stars
Verified 2026-10-09. HTTP 200. https://github.com/chenglou/pretext (HTTP 200, page fetched 2026-10-09), https://github.com/chenglou/pretext (GitHub API, 50724 stars), depo.zip listing https://www.depo.zip/tools/j5762g7s918y0cgpbn1n1m18dx83t7gk








