Created
July 31, 2019 08:13
-
-
Save omnikron/145c20cfd83d7aaa9b6d0613fded9a32 to your computer and use it in GitHub Desktop.
dynamic defer
This file contains hidden or 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
<html> | |
<head> | |
<script> | |
//var sdkURL = "blah"; | |
//if (window.location.href.indexOf("testUI=enabled") >= 0) { | |
// sdkURL += "&loadTesting"; | |
//} | |
var scriptTag = document.createElement('script'); | |
scriptTag.type = 'text/javascript' | |
var code = "window.alert('initial dynamic')" | |
scriptTag.appendChild(document.createTextNode(code)); | |
scriptTag.setAttribute('defer', 'true'); | |
scriptTag.defer; | |
document.head.appendChild(scriptTag); | |
</script> | |
<script> | |
setTimeout(() => { | |
var scriptTag = document.createElement('script'); | |
scriptTag.type = 'text/javascript' | |
var code = "window.alert('timeout dynamic')" | |
scriptTag.appendChild(document.createTextNode(code)); | |
scriptTag.setAttribute('defer', 'true'); | |
document.head.appendChild(scriptTag); | |
}, 100); | |
</script> | |
<script defer="true"> | |
window.alert('defer=true'); | |
</script> | |
<script defer="defer"> | |
window.alert('defer=defer'); | |
</script> | |
<script defer> | |
window.alert('defer'); | |
</script> | |
<script> | |
window.alert('no defer'); | |
</script> | |
</head> | |
<body> | |
<p>Something</p> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment