Skip to content

Instantly share code, notes, and snippets.

@deezone
Created May 19, 2020 11:56
Show Gist options
  • Save deezone/0fcd4d8b73b17ffbf3c5ee19e9c99372 to your computer and use it in GitHub Desktop.
Save deezone/0fcd4d8b73b17ffbf3c5ee19e9c99372 to your computer and use it in GitHub Desktop.
WASM - DOM Access - index.html
<!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