l l , i|,' /,'l ,/ l' / ____ l |i l l, l | l| | .l l /-l' /,'''T / ``''l |l l |l .l l |l | l l ,li l//,,_ |/ ,.- .l|,l | |ヽ| l.|/l l|i | /i l/_,,,,._ l '" ̄`` |l | l |.l l || l .|l, | l |'"´ l,l| | |イ | | .lヽ、ll l |l l /l l .l|i .| . | l ヽ、l l l`、 ', 'ノl ij ,. | . | l ヽ、', l\. _,,...., /l| /l | | . | | l ヽl、'l `i、 `- ' /| l'ィ/ | .| l |i l `、ヽ、 l `|l 、_ ,. '|| .| ./l/ ,/| | | |l .|、 ヽ ` | il ` ´. ,l,l、 l / / | | . l .|i |l`、 ヽ ,.-'´l`‐、_ _,..-' |:::`‐'、/_ | |, l |l |l,.',..イ::::::::::l `/ヽ .|::::::::::::ヽ::`‐-l|
*
* Again: this will **not** prevent inline script, e.g.:
* .
*
* This workaround is possible because Safari supports the non-standard 'beforeload' event.
* This allows us to trap the module and nomodule load.
*
* Note also that `nomodule` is supported in later versions of Safari - it's just 10.1 that
* omits this attribute.
* -->
*/
(function () {
const check = document.createElement('script');
if (!('noModule' in check) && 'onbeforeload' in check) {
let support = false;
document.addEventListener(
'beforeload',
(e) => {
if (e.target === check) {
support = true;
} else if (!e.target.hasAttribute('nomodule') || !support) {
return;
}
e.preventDefault();
},
true,
);
check.type = 'module';
const blob = URL.createObjectURL(
new window.Blob([], { type: 'text/javascript' }),
);
check.src = blob;
check.onload = () => {
URL.revokeObjectURL(blob);
};
document.head.appendChild(check);
check.remove();
}
})();