Skip to content

Instantly share code, notes, and snippets.

@jrunning
Last active March 24, 2017 18:14
Show Gist options
  • Save jrunning/d0404cb9fdc32fd8b645bbf00b342495 to your computer and use it in GitHub Desktop.
Save jrunning/d0404cb9fdc32fd8b645bbf00b342495 to your computer and use it in GitHub Desktop.
load-order-test
<script src="test-script.js"></script>
<script>
console.log('Hello from test-child.html');
</script>
<!-- output:
Hello from test-script.js
Hello from test-child.html
-->
<!doctype html>
<html>
<body>
<iframe src="test-child.html"></iframe>
<script>
console.log('Hello from test-iframe-parent.html');
</script>
</body>
</html>
<!-- output:
Hello from test-iframe-parent.html
Hello from test-script.js
Hello from test-child.html
-->
<!doctype html>
<html>
<body>
<link rel="import" href="test-child.html"/>
<script>
console.log('Hello from test-import-parent.html');
</script>
</body>
</html>
<!-- output:
Hello from test-script.js
Hello from test-child.html
Hello from test-import-parent.html
-->
<!doctype html>
<html>
<body>
<script>
let template = document.createElement('template');
template.innerHTML = `
<script src="test-script.js">\x3c/script>
<script>
console.log('Hello from imported template content');
\x3c/script>
`;
document.body.appendChild(document.importNode(template.content, true));
console.log('Hello from test-inject-parent.html');
</script>
</body>
</html>
<!-- output:
Hello from imported template content
Hello from test-inject-parent.html
Hello from test-script.js
-->
console.log('Hello from test-script.js');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment