diff --git a/packages/rrweb-snapshot/src/rebuild.ts b/packages/rrweb-snapshot/src/rebuild.ts index f83ac0bc0b..b8c22bd74e 100644 --- a/packages/rrweb-snapshot/src/rebuild.ts +++ b/packages/rrweb-snapshot/src/rebuild.ts @@ -7,7 +7,12 @@ import { type legacyAttributes, } from '@rrweb/types'; import { type tagMap, type BuildCache } from './types'; -import { isElement, Mirror, isNodeMetaEqual } from './utils'; +import { + isElement, + Mirror, + isNodeMetaEqual, + extractFileExtension, +} from './utils'; import postcss from 'postcss'; const tagMap: tagMap = { @@ -265,15 +270,14 @@ function buildNode( } else if ( tagName === 'link' && (n.attributes.rel === 'preload' || - n.attributes.rel === 'modulepreload') && - n.attributes.as === 'script' + n.attributes.rel === 'modulepreload') ) { // ignore } else if ( tagName === 'link' && n.attributes.rel === 'prefetch' && typeof n.attributes.href === 'string' && - n.attributes.href.endsWith('.js') + extractFileExtension(n.attributes.href) === 'js' ) { // ignore } else if ( diff --git a/packages/rrweb-snapshot/src/snapshot.ts b/packages/rrweb-snapshot/src/snapshot.ts index 0e8ec68be9..35f21b1a58 100644 --- a/packages/rrweb-snapshot/src/snapshot.ts +++ b/packages/rrweb-snapshot/src/snapshot.ts @@ -820,8 +820,7 @@ function slimDOMExcluded( // (module)preload link (sn.tagName === 'link' && (sn.attributes.rel === 'preload' || - sn.attributes.rel === 'modulepreload') && - sn.attributes.as === 'script') || + sn.attributes.rel === 'modulepreload')) || // prefetch link (sn.tagName === 'link' && sn.attributes.rel === 'prefetch' &&