Skip to content

Commit e3a066e

Browse files
authored
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 b4de70f commit e3a066e

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

packages/rrweb-snapshot/src/rebuild.ts

+6
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@ export function addHoverClass(cssText: string, cache: BuildCache): string {
6969
const cachedStyle = cache?.stylesWithHoverClass.get(cssText);
7070
if (cachedStyle) return cachedStyle;
7171

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

0 commit comments

Comments
 (0)