mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-14 06:50:01 -04:00
add meta rewriting and bundle preloading
This commit is contained in:
parent
fb6240b535
commit
8b2757b495
2 changed files with 12 additions and 2 deletions
|
@ -40,7 +40,9 @@ function traverseParsedHtml(node, origin?: string) {
|
|||
delete node.attribs.csp;
|
||||
}
|
||||
} else if (node.name === "link") {
|
||||
if (hasAttrib(node, "integrity")) {
|
||||
delete node.attribs.integrity;
|
||||
}
|
||||
|
||||
node.attribs.href = encodeUrl(node.attribs.href, origin);
|
||||
|
||||
|
@ -52,7 +54,9 @@ function traverseParsedHtml(node, origin?: string) {
|
|||
} else if (node.name === "style") {
|
||||
node.children[0].data = rewriteCss(node.children[0].data, origin);
|
||||
} else if (node.name === "script") {
|
||||
if (hasAttrib(node, "integrity")) {
|
||||
delete node.attribs.integrity;
|
||||
}
|
||||
|
||||
if (hasAttrib(node, "type") && /(application|text)\/javascript|importmap/.test(getAttributeValue(node, "type"))) {
|
||||
if (hasAttrib(node, "src")) {
|
||||
|
@ -102,6 +106,10 @@ function traverseParsedHtml(node, origin?: string) {
|
|||
node.attribs.src = encodeUrl(node.attribs.src, origin);
|
||||
} else if (node.name === "video") {
|
||||
node.attribs.src = encodeUrl(node.attribs.src, origin);
|
||||
} else if (node.name === "meta") {
|
||||
if (hasAttrib(node, "http-equiv") && node.attribs["http-equiv"] === "content-security-policy") {
|
||||
delete node.attribs["http-equiv"];
|
||||
}
|
||||
}
|
||||
|
||||
if (node.childNodes) {
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Document</title>
|
||||
<link rel="preload" as="script" href="./scramjet.worker.js">
|
||||
<link rel="preload" as="script" href="./scramjet.bundle.js">
|
||||
</head>
|
||||
<body>
|
||||
<script src="https://unpkg.com/dreamland"></script>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue