You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Only accept the bridge namespaced payloads for height updates and forward other messages to consumers. SizedWebView now checks that JS messages are strings starting with the bridge prefix before calling setHeightFromPayload; unprefixed payloads are passed to the caller's onMessage. useAutoHeight.parseHeightPayload was tightened to accept only numbers or prefixed bridge strings (bare numeric strings are rejected).
The injected AUTO_HEIGHT_BRIDGE script was optimized: added a domDirty flag (set by the MutationObserver and cleared after pruning) so pruneTrailingNodes runs only when structure changed; prefer the wrapper element as the single authoritative reflow target to avoid multiple forced layouts; and other small measurement-path simplifications to reduce reflows and work per frame.
Documentation: README gains a “Built for speed” section describing hot-path complexity and rationale for the optimizations.
Copy file name to clipboardExpand all lines: README.md
+15Lines changed: 15 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -142,6 +142,21 @@ The example showcases:
142
142
| Scrolling in parent `ScrollView`| Nested scroll can fight gestures | Parent retains full momentum and gesture priority |
143
143
144
144
Benchmarks were captured on CMS articles up to 3k words in a 60 fps RN dev build. The bridge batches DOM mutations so even long documents resize without thrashing the JS thread.
145
+
146
+
### 🏎️ Built for speed
147
+
148
+
Every hot path is designed to run at its theoretical complexity floor — no allocations in steady state, no repeated DOM walks, and at most one forced layout per measurement frame.
| Height commit (rAF-batched) |**O(1)** amortized per frame | Sub-pixel diffs are dropped; at most one React render per animation frame. |
154
+
| DOM mutation callback |**O(added nodes)**| Scans only each mutation's `addedNodes`, not the whole tree. Media elements are deduped via a `WeakSet`. |
155
+
|`measureHeight`|**1 forced reflow / call**| Reads the wrapper element only — its box is authoritative because every `<body>` child lives inside it. |
156
+
| Trailing-node prune DFS | Runs only when the DOM is **dirty**| A mutation-driven dirty flag skips the recursive walk on resize / font / viewport ticks when nothing structural changed. |
157
+
158
+
The net effect: resize storms, font loads, and viewport changes cost a single `getBoundingClientRect()` per frame — nothing more. Paired with `sideEffects: false` and named-only exports, the library stays fast *and* small in the final bundle.
159
+
145
160
### 📦 Bundle & tree-shaking
146
161
147
162
- Ships as ESM-first (`lib/module/**`) with `"sideEffects": false`.
0 commit comments