[Feature Request]: Buffering events before loading library and calling `record`
Preflight Checklist
- [X] I have searched the issue tracker for a feature request that matches the one I want to file, without success.
What package is this feature request for?
rrweb
Problem Description
We need to defer calling record() but would still like to capture mutations that occur before record() is called.
Proposed Solution
A potential solution here is to initialize a MutationObserver elsewhere (e.g. in a <script> in the html body before your JS bundle is loaded) and start a buffer that can later be passed to rrweb which can process them.
Alternatives Considered
N/A
Additional Information
No response
Actually, we are having more and more observers other than the core MutationObserver, so only initializing the MutationObserver still misses some events.
Could you share why you do not put rrweb in the HTML body before the JS bundle if you need that kind of feature? Is bundle size an issue?
Yeah bundle size is the main concern. Additionally, we would like to put loading the library behind a feature flag, which happens much later down the line and we would like to capture the DOM state when it's initially loaded.