Repository navigation
perf: update periodic panel text without replacing child nodes - #350
Merged
Merged
Conversation
On logged-in Binance futures pages every write that removes all children of an element (textContent/innerHTML assignment, replaceChildren) makes Chrome re-evaluate :has() on its ancestors, and Binance's price-alert rule `.price-alert-modal :has(>div.bn-skeleton)>:not(.bn-skeleton)` turns that into a whole-body style recalculation (~45-60 ms over ~14k elements). A 6 s trace during a continuous close spent 1476 of 1540 ms of style recalcs in 44 such recalcs; a live A/B removing only that rule removed all of them. While idle, every trigger came from these userscripts. Add setElementText (src/shared/dom-text.js), which updates the existing Text node's data instead: - orderbook 2.7.248: status line, rebalance status, cancel button, quantity labels, side buttons, hint, depth-profile toggle/status; - trading-data 1.2.8: one-second footer clock and funding cells; - Strategy 29 0.5.18: all dynamic summary text, and unit/signal rows rebuild only when their rendered content changes. The CoinMarketCap panel is unchanged: its 30 s refresh always changes the fetch time and rebuilds in one task. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On logged-in Binance futures pages, Binance's price-alert CSS rule
.price-alert-modal :has(>div.bn-skeleton)>:not(.bn-skeleton)makes every "remove all children" write (assigningtextContent/innerHTML,replaceChildrenon an element with children) trigger a whole-body style recalculation (~45–60 ms over ~14k elements).renderStatus, trading-dataupdateFooter, CMC, orderbooksetLadderStatus).crossoriginbreaks the whole chunk CSS for browsers with an existing no-cors cache entry (CDN omits ACAO andVary: Originwithout an Origin header).Change
src/shared/dom-text.jssetElementText: update the single existing Text node'sdata; unchanged values are not written.docs/userscript-validation.md.Validation
characterData-only changes (orderbook ladder status e2e, trading-data panel, Strategy 29 polls, helper unit tests); each fails on the previous code. A control test keeps real content changes rebuilding rows.:empty.npm test2666 passed;npm run test:ui671 passed; builds,lint:tests,lint:ui-copy,check:binance-userscripts,check:binance-orderbook-trade,git diff --checkpass. Generated versions match sources; CMC artifact unchanged.🤖 Generated with Claude Code