Demo of `document.currentScript` polyfill
HTML
<script src="https://rawgit.com/JamesMGreene/fb4a71e060da6e26511d/raw/76893c67ea3a88ef2eeefc5daecbff64c2d9aa63/document.currentScript.js"></script>
<script src="https://rawgit.com/JamesMGreene/79c0cbb29addd5eefd14/raw/2e2e5382097f2ca65bfde4f1c2738206408831dc/test.js"></script>
<!doctype html>
<html>
<head>
<title>currentScript Example</title>
<script type="text/javascript" id="mainscript" async>
debugger
console.log(document.currentScript);
if (document.currentScript.async) {
console.log("Executing asynchronously");
} else {
console.log("Executing synchronously");
}
</script>
</head>
<body>
<p>Demonstration of <code>beforescriptexecute</code> and
<code>afterscriptexecute</code>.</p>
<h3>Output</h3>
<ul id="output">
</ul>
</body>
</html>
JavaScript
/*
Polyfill script:
https://github.com/JamesMGreene/document.currentScript
*/