Skip to content
Open
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
19 changes: 19 additions & 0 deletions src/rebuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,25 @@ function buildNode(
case NodeType.Element:
const tagName = getTagName(n);
let node: Element;

// exclude some js load by pre*
if (
tagName === 'link' &&
(
/prefetch|preload/.test(n!.attributes!.rel as string) &&
/\.js$/.test(n.attributes.href as string)
)
) {
node = document.createElement('noscript');
node.setAttribute('src', n.attributes.href as string);
return node;
}

// exclude icon load
if (tagName === 'link' && n!.attributes!.rel === 'icon') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the problem if we rebuild a link element with icon?

return document.createElement('link');
}

if (n.isSVG) {
node = doc.createElementNS('http://www.w3.org/2000/svg', tagName);
} else {
Expand Down