You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've applied SRI to my initial application load. My challenge lies with dynamically imported assets that are fetched and injected into the HTML at runtime. Rollup's default behavior doesn't seem to support SRI for these. I've checked available plugins, but they all focus on initial load SRI. Are there any plugins or tips for implementing SRI on runtime-injected dynamic imports?
let t = Promise.resolve();
if (n && n.length > 0) {
const i = document.getElementsByTagName("link")
, a = document.querySelector("meta[property=csp-nonce]")
, l = a?.nonce || a?.getAttribute("nonce");
t = Promise.all(n.map(c => {
if (c = yi(c, o),
c in en)
return;
en[c] = !0;
const s = c.endsWith(".css")
, u = s ? '[rel="stylesheet"]' : "";
if (!!o)
for (let h = i.length - 1; h >= 0; h--) {
const f = i[h];
if (f.href === c && (!s || f.rel === "stylesheet"))
return
}
else if (document.querySelector(`link[href="${c}"]${u}`))
return;
const d = document.createElement("link");
if (d.rel = s ? "stylesheet" : fi,
s || (d.as = "script",
d.crossOrigin = ""),
d.href = c,
l && d.setAttribute("nonce", l),
document.head.appendChild(d),
s)
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I've applied SRI to my initial application load. My challenge lies with dynamically imported assets that are fetched and injected into the HTML at runtime. Rollup's default behavior doesn't seem to support SRI for these. I've checked available plugins, but they all focus on initial load SRI. Are there any plugins or tips for implementing SRI on runtime-injected dynamic imports?
Beta Was this translation helpful? Give feedback.
All reactions