Learn Pretext.js — the JavaScript Text Measurement Library

Interactive tutorials and live demos for pretext (pretext.js) — the zero-dependency JavaScript library by Cheng Lou that measures multiline text height, line breaks, and width with pure arithmetic. No DOM reads, no layout thrashing, no forced reflow — hundreds of times faster than getBoundingClientRect().

Note: this is the pretext JavaScript library, not PreTeXt the math-textbook authoring language.

Enable JavaScript for the full interactive experience — a live canvas newspaper where text reflows around draggable images at 60fps.