Comparing
Fast multiline text measurement and layout without DOM reflow
3D graphics in the browser — WebGL-powered scenes, lights, cameras, and geometries with a beginner-friendly JavaScript API.
| Metric | @chenglou/pretext | three |
|---|---|---|
| Ecosystem | npm | npm |
| Difficulty | Intermediate ✓ | Advanced |
| Weekly downloads | 0 | 3.0M↑ |
| Latest version | v0.0.3 | v0.170.0 |
| Recipes | 5↑ | 2 |
@chenglou/pretext only
Shared
three only
Use pretext when you need to know text dimensions before rendering — virtualised scrolling lists where you must know item heights upfront, text flowing around images or arbitrary obstacles, dynamic subtitle/caption positioning, detecting content overflow at build time, or any animation that requires text metrics on every frame.
3D product viewers, data visualizations in 3D, games, interactive art, generative design, architecture visualization, any WebGL experience.
Pretext only measures plain text — it cannot handle HTML markup, inline images, or mixed rich content. For simple cases where you measure a single element once on mount, the browser's built-in ResizeObserver or getBoundingClientRect is simpler and sufficient. Pretext's two-phase API adds conceptual overhead that is only justified when measurements are frequent or happen before render.
2D graphics (use canvas API or SVG), simple CSS animations, when you need a full game engine (use Babylon.js or Unity WebGL).
@chenglou/pretext
+1 more
three