MDN self-hosted library · e01.org

Async scripts for asm.js

Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.

html
<script async src="file.js"></script>
js
const script = document.createElement("script");
script.src = "file.js";
document.body.appendChild(script);
html
<script async>
  // Inline JavaScript code
</script>
js
const script = document.createElement("script");
script.textContent = "// Inline JavaScript code";
document.body.appendChild(script);
js
const blob = new Blob([codeString]);
const script = document.createElement("script");
const url = URL.createObjectURL(blob);
script.onload = script.onerror = () => URL.revokeObjectURL(url);
script.src = url;
document.body.appendChild(script);