Created
May 19, 2020 11:56
-
-
Save deezone/0fcd4d8b73b17ffbf3c5ee19e9c99372 to your computer and use it in GitHub Desktop.
WASM - DOM Access - index.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
<!doctype html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>SoulCycle Go Wasm</title> | |
<script src="wasm_exec.js"></script> | |
<script> | |
if (WebAssembly) { | |
// For browsers that do not support WebAssembly.instantiateStreaming | |
if (WebAssembly && !WebAssembly.instantiateStreaming) { // polyfill | |
WebAssembly.instantiateStreaming = async (resp, importObject) => { | |
const source = await (await resp).arrayBuffer(); | |
return await WebAssembly.instantiate(source, importObject); | |
}; | |
} | |
const go = new Go(); | |
WebAssembly.instantiateStreaming(fetch("main.wasm"), go.importObject).then((res) => { | |
go.run(res.instance); | |
}); | |
} else { | |
console.log("WebAssembly is not supported in your browser") | |
} | |
function updateDOM(text) { | |
document.getElementById("wasm").innerText = text; | |
} | |
</script> | |
</head> | |
<body> | |
<main id="wasm"></main> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment