Last active
October 30, 2019 12:10
-
-
Save cooljl31/b291b1b44a72dbd7ca3bab3e6f6b3032 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
<!-- use a module script to detect modern browsers: --> | |
<script type=module> | |
self.modern = true | |
</script> | |
<!-- now use that flag to load modern VS legacy code: --> | |
<script defer> | |
addEventListener('load', function () { | |
var s = document.createElement('script') | |
if (self.modern) { | |
s.src = './module.js' | |
s.type = 'module' | |
s.defer = true | |
s.async = true | |
} | |
else { | |
s.src = './module.js' | |
s.defer = 'defer' | |
s.async = 'async' | |
} | |
document.head.appendChild(s) | |
}) | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment