← The log

chenglou/pretext

★ 50,837 stars

TypeScript

Covered in week 2026-W22 · the 2026-05 report

Fast, accurate & comprehensive text measurement & layout

What pretext is

Pretext side-steps the need for DOM measurements (e.g. getBoundingClientRect, offsetHeight), which trigger layout reflow, one of the most expensive operations in the browser. It implements its own text measurement logic, using the browsers' own font engine as ground truth (very AI-friendly iteration method).

From the repository README · read it on GitHub →

31 May 2026 · 0:36
500x Faster Text Layout in 15KB, Zero Dependencies, by a React Core + Midjourney — Free #Shorts
Watch on YouTube →

Transcript

Every getBoundingClientRect call forces a full layout reflow and wrecks your app's performance. Pretext just hit 47,000 stars by eliminating DOM text measurement entirely. It measures and lays out multiline text in pure JavaScript, supporting every language from Chinese to Arabic to emoji. The resize hot path is pure arithmetic on cached widths, so you get zero layout shift, proper virtualization, and no more guessing text heights. Built by the creator of ReasonML. Worth a star? Link in description.

View on GitHub