Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/rrweb-snapshot/src/rebuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,8 @@ function buildNode(
continue;
} else if (
tagName === 'link' &&
n.attributes.rel === 'preload' &&
(n.attributes.rel === 'preload' ||
n.attributes.rel === 'modulepreload') &&
n.attributes.as === 'script'
) {
// ignore
Expand Down
5 changes: 3 additions & 2 deletions packages/rrweb-snapshot/src/snapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -813,9 +813,10 @@ function slimDOMExcluded(
slimDOMOptions.script &&
// script tag
(sn.tagName === 'script' ||
// preload link
// (module)preload link
(sn.tagName === 'link' &&
sn.attributes.rel === 'preload' &&
(sn.attributes.rel === 'preload' ||
sn.attributes.rel === 'modulepreload') &&
sn.attributes.as === 'script') ||
// prefetch link
(sn.tagName === 'link' &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@ exports[`integration tests [html file]: preload.html 1`] = `
<title>Document</title>
<link />
<link />
<link />
</head>
<body></body></html>"
`;
Expand Down
1 change: 1 addition & 0 deletions packages/rrweb-snapshot/test/html/preload.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<link rel="modulepreload" href="https://example/path/to/preload.js" as="script" />
<link rel="preload" href="https://example/path/to/preload.js" as="script" />
<link rel="prefetch" href="https://example/path/to/prefetch.js" />
</head>
Expand Down