Skip to content

Commit

Permalink
feat(replay): Skip addHoverClass when stylesheet is >= 1MB (#130)
Browse files Browse the repository at this point in the history
Large stylesheets will cause `addHoverClass` to block the main UI thread
when viewing a replay. Turn this off when stylesheet is >= 1MB.
  • Loading branch information
billyvg authored Nov 8, 2023
1 parent b4de70f commit e3a066e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/rrweb-snapshot/src/rebuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
Expand Down

0 comments on commit e3a066e

Please sign in to comment.