perf(snapshot): avoid recreate element a every time (#1387)

perf(snapshot): avoid costly generation of <a> element on each call to `getHref`, instead cache an anchor element and reuse it's href attributed

---------

Co-authored-by: Eoghan Murray <eoghan@getthere.ie>
This commit is contained in:
Vinicius Lourenço
2024-05-02 09:44:58 -03:00
committed by GitHub
parent f1e6a51dc6
commit 5e7943dbae
2 changed files with 30 additions and 10 deletions

View File

@@ -0,0 +1,10 @@
---
'rrweb-snapshot': patch
---
Avoid recreating the same element every time, instead, we cache and we just update the element.
Before: 779k ops/s
After: 860k ops/s
Benchmark: https://jsbench.me/ktlqztuf95/1