wuyifan-code669 downloadsIntegrates Pretext library to reduce DOM measurement overhead in Obsidian's rendering pipeline, improving performance for large documents.
Reduce DOM measurement overhead during rendering, improving performance for large documents.
Version: 1.2.2 | Requires: Obsidian 1.10+
中文文档 · 中文文档 — see README_zh.md for the Chinese version.
When you open a note, Obsidian needs to measure the actual occupied size of text to set heights — this is called DOM measurement. Every measurement touches the render tree and is expensive. Pretext calculates heights at build time and sets min-height directly, letting the browser skip measurement.
Effects:
MarkdownPostProcessor captures the render, uses Pretext to compute height, sets min-heightCodeMirrorExtension does the same on editor lines (Obsidian 1.5+)observeHeavyElements() now only scans the visible content area, not the whole documentrequestAnimationFrame to prevent duplicate processingrequestIdleCallback for schedulingBRAT: Add a beta plugin → enter wuyifan-code/Obsidian-pretext.obsidian/plugins/obsidian-pretext/npm install
npm test # run tests
npm run typecheck
npm run build # build main.js
src/
├── analysis/ # tokenization, punctuation, whitespace
│ ├── segmentation.ts
│ ├── punctuation.ts
│ └── whitespace.ts
├── hooks/ # Obsidian extension points
│ ├── CodeMirrorExtension.ts
│ ├── MarkdownPostProcessor.ts
│ └── HeavyElementOptimizer.ts
├── PretextManager.ts # Pretext core manager
└── MeasurementCache.ts # measurement result cache
MIT — see LICENSE.
Powered by Pretext by Cheng Lou
减少渲染时的 DOM 测量开销,提升大型文档的渲染性能。
版本: 1.2.2 | 要求: Obsidian 1.10+
在你的笔记打开时,Obsidian 需要测量文本的实际占用来设置高度——这叫 DOM 测量。每次测量都要访问渲染树,开销很大。Pretext 在构建时就算好高度,直接设置 min-height,让浏览器跳过测量。
效果:
MarkdownPostProcessor 捕获渲染,用 Pretext 计算高度,设置 min-heightCodeMirrorExtension 在编辑器行上做同样处理(Obsidian 1.5+)observeHeavyElements() 现在只扫描可见内容区域,不扫整个 documentrequestAnimationFrame 节流,防止重复处理requestIdleCallback 分批处理BRAT: Add a beta plugin → 输入 wuyifan-code/Obsidian-pretext.obsidian/plugins/obsidian-pretext/npm install
npm test # 运行测试
npm run typecheck
npm run build # 构建 main.js
src/
├── analysis/ # 分词、标点、空白处理模块
│ ├── segmentation.ts
│ ├── punctuation.ts
│ └── whitespace.ts
├── hooks/ # Obsidian 扩展点
│ ├── CodeMirrorExtension.ts
│ ├── MarkdownPostProcessor.ts
│ └── HeavyElementOptimizer.ts
├── PretextManager.ts # Pretext 核心管理
└── MeasurementCache.ts # 测量结果缓存
MIT License。