Created
September 29, 2015 19:19
-
-
Save andrewagain/a28a47f1364dfac1f98b 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
<head> | |
<script type='text/javascript'> | |
console.log('main-tag'); | |
document.write('<script type=\"text/javascript\" src="http://cdn.ahf.io/remote.js"><\/scr'+'ipt>'); | |
</script> | |
</head> | |
<body> | |
Body | |
<script type='text/javascript'> | |
console.log('end-of-body-tag'); | |
</script> | |
</body> |
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
<head> | |
<script type='text/javascript'> | |
console.log('main-tag'); | |
var head = document.getElementsByTagName('head').item(0); | |
var script = document.createElement('script'); | |
script.setAttribute('type', 'text/javascript'); | |
script.setAttribute('src', 'http://cdn.ahf.io/remote.js'); | |
head.appendChild(script); | |
</script> | |
</head> | |
<body> | |
Body | |
<script type='text/javascript'> | |
console.log('end-of-body-tag'); | |
</script> | |
</body> |
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
console.log('remote-tag'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I believe adding a script tag with document.write causes it to run immediately.
Run the 2 HTML files and look at the console.
nodeadd.html
output:docwrite.html
output: