Created
May 19, 2020 11:12
-
-
Save deezone/e9d01ed993482bf89a460d02437e6d40 to your computer and use it in GitHub Desktop.
WASM - Hello World - 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
<!-- /out/index.html --> | |
<!doctype html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Go Wasm</title> | |
</head> | |
<body> | |
<script src="wasm_exec.js"></script> | |
<script> | |
if (WebAssembly) { | |
// WebAssembly.instantiateStreaming is not currently available in Safari | |
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") | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment