Skip to content
IndexDesign corpus
Component LibrariesPrimitiveFreeVanilla JS

Pretext

Fast JavaScript text measurement and multiline layout without DOM reflow

Aboutgithub.com

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.

Install
npm install @chenglou/pretext
For an agent

Use 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.

Install command, framework, licence and component list.
Notable for
  • No DOM reflow
  • DOM
  • Canvas
  • and SVG output
  • 50
  • 000+ GitHub stars
Provenance

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

Related resourcesComponent Libraries