Created
January 10, 2019 03:28
-
-
Save weirdpattern/9ed573e049cb01c4a47c391e846ac631 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
2019.01.09.script-loading-techniques |
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
<html> | |
<head> | |
<title>Loading scripts</title> | |
<script src="script1.js" defer></script> | |
<script src="script2.js" async></script> | |
</head> | |
<body> | |
<!-- Inline block 1 --> | |
<script type="text/javascript"> | |
document.querySelector('#test').innerHTML = 'This is a test from inline block 1'; | |
</script> | |
<div id="test"></div> | |
<!-- Inline block 2 --> | |
<script type="text/javascript"> | |
document.querySelector('#test').innerHTML = 'This is a test from inline block 2'; | |
</script> | |
</body> | |
</html> |
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
document.querySelector('#test').innerHTML = 'This is a test from script 1'; |
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
document.querySelector('#test').innerHTML = 'This is a test from script 2'; |
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
<script [defer|async] src="[js-file]"></script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment