github.com/egonelbre/exp@v0.0.0-20240430123955-ed1d3aa93911/wasmcanvas/index.html (about)

     1  <!doctype html>
     2  <html>
     3  <head>
     4  	<meta charset="utf-8">
     5  	<title>Canvas</title>
     6  </head>
     7  <body>
     8  	<canvas id="view" style="border: 1px solid;"></canvas>
     9  	<image id="image" src="tile.png"></image>
    10  
    11  	<script src="wasm_exec.js"></script>
    12  	<script>
    13  		if (!WebAssembly.instantiateStreaming) { // polyfill
    14  			WebAssembly.instantiateStreaming = async (resp, importObject) => {
    15  				const source = await (await resp).arrayBuffer();
    16  				return await WebAssembly.instantiate(source, importObject);
    17  			};
    18  		}
    19  
    20  		const go = new Go();
    21  		let mod, inst;
    22  		WebAssembly.instantiateStreaming(fetch("wasmcanvas.wasm"), go.importObject).then((result) => {
    23  			mod = result.module;
    24  			inst = result.instance;
    25  			go.run(inst);
    26  		}).catch((err) => {
    27  			console.error(err);
    28  		});
    29  	</script>
    30  </body>
    31  
    32  </html>