Skip to content

Throttle high-frequency events and slim non-visible DOM in rrweb record() (#44) - #47

Open
SaintPepsi wants to merge 1 commit into
mainfrom
fix/44-sampling-slim-dom
Open

Throttle high-frequency events and slim non-visible DOM in rrweb record() (#44)#47
SaintPepsi wants to merge 1 commit into
mainfrom
fix/44-sampling-slim-dom

Conversation

@SaintPepsi

@SaintPepsi SaintPepsi commented Jul 22, 2026

Copy link
Copy Markdown
Owner

Summary

  • REPLAY_DESIGN.md §4 specced sampling (throttle mousemove/scroll/media, dedupe input to last-value) and slimDOMOptions (drop <script>/preload tags, comments, and non-visible <head> metadata from DOM snapshots) alongside the other record() tuning — neither made it into the actual record() call in src/rrweb-recorder.js.
  • Both are free wins: nothing here drops replay fidelity. Sampling only removes redundant intermediate samples within a throttle window (a human was never going to scrub to the mousemove between two 50ms-apart samples); slimDOMOptions only strips DOM nodes that are never rendered in the first place (<script> tags, HTML comments, favicon links, SEO/social meta tags).
  • slimDOMOptions here deliberately turns on headMetaAuthorship/headMetaDescKeywords — more aggressive than rrweb's own slimDOMOptions: true shorthand, which leaves those two off because they can carry info some consumers want to keep. A bug report's replay has no use for a page's meta description or author tag, so the full object from REPLAY_DESIGN.md is used as specced rather than the shorthand.

This is the smallest of the 3 mitigations from my comment on #44 (image encoding is #45, event-stream compression is #46) — it's additive to both and doesn't touch the same code paths.

Test plan

  • npm run build — clean
  • bun test test/recorder.test.js — 9/9 pass, including new causal-guard assertions on capturedOpts.sampling and capturedOpts.slimDOMOptions (mirroring the existing inlineImages guard)
  • bun test test/ — 88/90 pass; the 2 failures (test/packaging.test.js) are pre-existing on main, unrelated to this change: one is a Windows path-separator artifact in the packaged-file check, the other is docs/STORE_LISTING.md genuinely missing CWS justification blocks for several permissions (a real doc gap, not a path issue) — confirmed by running the same test against unmodified main
  • Disconfirming input: manually reverted the sampling/slimDOMOptions lines in src/rrweb-recorder.js and reran test/recorder.test.js — the new assertions go red as expected

🤖 Generated with Claude Code


Note: #45 (fix/44-webp-inline-images) edits the same record({...}) call block in src/rrweb-recorder.js. Both are independent, non-stacked PRs — merging both will hit a textual (not semantic) conflict at that call site that needs manual reconciliation; the options compose fine (inlineImages, dataURLOptions, sampling, slimDOMOptions are all independent keys).

…rd()

REPLAY_DESIGN.md §4 specced sampling (throttle mousemove/scroll/media/input)
and slimDOMOptions (drop <script>/comment/non-visible <head> metadata from
snapshots) alongside the other record() tuning, but neither made it into the
actual record() call in src/rrweb-recorder.js.

Smaller win than the image/compression fixes (#45, #46) but free: none of
this drops replay fidelity — it only removes redundant intermediate samples
and DOM nodes that were never rendered.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant