1
0
mirror of https://github.com/taigrr/wasm-experiments synced 2025-01-18 04:03:21 -08:00

Add vugu example

This commit is contained in:
Johan Brandhorst
2019-06-23 16:11:22 +01:00
parent 54313e0f51
commit 5a5d3084d5
8 changed files with 338 additions and 2 deletions

32
vugu/index.html Normal file
View File

@@ -0,0 +1,32 @@
<!doctype html>
<html>
<head>
<script src="/wasm_exec.js"></script>
</head>
<body>
<div id="target">
<img style="position: absolute; top: 50%; left: 50%;"
src="https://cdnjs.cloudflare.com/ajax/libs/galleriffic/2.0.1/css/loader.gif">
</div>
<script>
var wasmSupported = (typeof WebAssembly === "object");
if (wasmSupported) {
if (!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((result) => {
go.run(result.instance);
});
} else {
document.getElementById("target").innerHTML = 'This application requires WebAssembly support. Please upgrade your browser.';
}
</script>
</body>
</html>