Last active
May 27, 2020 12:56
-
-
Save developit/463a1ea6f6a92f35ede6eff9599e0684 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Demo: Treat Safari 11 and Prior as nomodule</title> | |
</head> | |
<body> | |
<script> | |
if (/Safari\/5/.test(navigator.userAgent)) { | |
var $fss = function () { | |
for (var i of document.scripts) { | |
if (i.noModule) { | |
i.noModule = false | |
var un = document.createElement('script') | |
for (var x of i.attributes) un.setAttribute(x.name, x.value) | |
i.parentNode.replaceChild(un, i) | |
} | |
} | |
} | |
addEventListener('DOMContentLoaded', $fss) | |
addEventListener('beforeload', function(e) { | |
if (e.target.type=='module') e.preventDefault() | |
$fss() | |
}, true) | |
} | |
</script> | |
<script type="module" src="hello.mjs"></script> | |
<script nomodule src="hello.js"></script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment