pretext-layout
by Roy Yuen
High-performance browser-based text layout and measurement for virtualization, canvas, and layout-heavy applications.
About This Skill
Efficient Text Measurement & Layout
The Pretext Layout skill enables AI agents to integrate and debug high-performance multiline text measurement using the @chenglou/pretext library. It solves the common frontend performance bottleneck of "layout thrashing" by replacing slow DOM-based height probes with a fast, browser-native API approach.
What it does
This skill provides developers with a structured methodology for measuring text width and height without repeated DOM reflows. It supports high-level block height calculation for virtualization and low-level line-by-line geometry for custom Canvas or SVG rendering workflows. It handles complex edge cases including web fonts, emoji, and bidirectional text.
Supported Workflows
- Virtualization: Pre-measure list item heights for smooth scroll anchoring.
- Custom Rendering: Extract per-line ranges for manual drawing in Canvas or SVG.
- Responsive Design: Rapidly recalculate layouts during window resize events on the hot path.
- Debugging: Verify layout accuracy against real-world CSS styles and font loading states.
Why use this skill?
While a general AI can write basic JavaScript, this skill understands the specific lifecycle of the Pretext library—such as partitioning the expensive "prepare" phase from the lightweight "layout" phase. It ensures your agent correctly manages browser-only runtime constraints, font loading promises, and locale-specific white-space behaviors to prevent layout shifts and flickering.
How to Install
unzip pretext-layout.zip -d ~/.claude/skills/Free
One-time purchase • Own forever
Security Scanned
Passed automated security review
Permissions
File Scopes
Tags
Public, sanitized export of the `pretext-layout` skill for browser-first `@chenglou/pretext` integration npm install @chenglou/pretext
Frequently Asked Questions
Learn More About AI Agent Skills
Similar Skills
code-reviewer
Reviews your code for bugs, security vulnerabilities, logic errors, performance issues, and style violations. Organizes findings by severity and suggests fixes with code examples.
git-commit-writer
Writes conventional commit messages by analyzing your staged git changes. Detects commit type, scope, and breaking changes automatically.
readme-generator
Generates a complete, polished README.md by scanning your actual project structure, dependencies, and code.
pr-description-writer
Writes clear pull request descriptions by analyzing your branch diff. Covers what changed, why, how, and what to test. Works with GitHub, GitLab, and Bitbucket.