Skip to content

Commit 379f068

Browse files
committed
feat(replay): Skip addHoverClass when stylesheet is >= 1MB (#130)
Large stylesheets will cause `addHoverClass` to block the main UI thread when viewing a replay. Turn this off when stylesheet is >= 1MB.
1 parent b9e05a7 commit 379f068

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

packages/rrweb-snapshot/src/rebuild.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,12 @@ export function adaptCssForReplay(cssText: string, cache: BuildCache): string {
7171
const cachedStyle = cache?.stylesWithHoverClass.get(cssText);
7272
if (cachedStyle) return cachedStyle;
7373

74+
if (cssText.length >= 1_000_000) {
75+
// Skip adding hover class for large stylesheets, otherwise we will run
76+
// into perf issues that will block main thread
77+
return cssText;
78+
}
79+
7480
const ast = parse(cssText, {
7581
silent: true,
7682
});

0 commit comments

Comments
 (0)