blog/themes/typing/source/js/sri-fallback.min.js

1 line
762 B
JavaScript

!function(){var a="x-sri-fallback";function o(e){var r=e.getAttribute&&e.getAttribute(a),i=(e.tagName||"").toLowerCase(),n="script"===i&&e.src?"src":"link"===i&&"stylesheet"===e.rel&&e.href?"href":null;r&&n&&(e.onerror=function(){var t=document.createElement(i);t.crossOrigin=e.crossOrigin,t.integrity=e.integrity,t[n]=r,"link"===i&&(t.rel=e.rel),t.onerror=function(){console.log("SRI fallback "+r+" also failed to match integrity string "+t.integrity+".")},document.head.appendChild(t)})}new MutationObserver(function(t){for(var e=0;e<t.length;++e){for(var r=t[e],i=r.addedNodes,n=0;n<i.length;++n)o(i[n]);r.attributeName===a&&o(r.target)}}).observe(document,{childList:!0,attributes:!0,characterData:!1,subtree:!0,attributeOldValue:!1,attributeFilter:[a]})}();