diff --git a/packages/rrweb-snapshot/src/rebuild.ts b/packages/rrweb-snapshot/src/rebuild.ts index f150ba41a8..bda5715adc 100644 --- a/packages/rrweb-snapshot/src/rebuild.ts +++ b/packages/rrweb-snapshot/src/rebuild.ts @@ -69,6 +69,12 @@ export function addHoverClass(cssText: string, cache: BuildCache): string { const cachedStyle = cache?.stylesWithHoverClass.get(cssText); if (cachedStyle) return cachedStyle; + if (cssText.length >= 1_000_000) { + // Skip adding hover class for large stylesheets, otherwise we will run + // into perf issues that will block main thread + return cssText; + } + const ast = parse(cssText, { silent: true, });