github.com/egonelbre/exp@v0.0.0-20240430123955-ed1d3aa93911/bench/wasmcall/index.html (about) 1 <!DOCTYPE html> 2 <!-- 3 Copyright 2018 The Go Authors. All rights reserved. 4 Use of this source code is governed by a BSD-style 5 license that can be found in the LICENSE file. 6 --> 7 <html> 8 <head> 9 <meta charset="utf-8" /> 10 <title>Go wasm</title> 11 </head> 12 13 <body> 14 <script src="wasm_exec.js"></script> 15 16 <script> 17 if (!WebAssembly.instantiateStreaming) { 18 // polyfill 19 WebAssembly.instantiateStreaming = async (resp, importObject) => { 20 const source = await (await resp).arrayBuffer(); 21 return await WebAssembly.instantiate(source, importObject); 22 }; 23 } 24 25 const go = new Go(); 26 27 let mod, inst; 28 29 WebAssembly.instantiateStreaming(fetch("lib.wasm"), go.importObject).then( 30 result => { 31 mod = result.module; 32 inst = result.instance; 33 go.run(inst); 34 inst = WebAssembly.instantiate(mod, go.importObject); // reset instance 35 } 36 ); 37 38 </script> 39 </body> 40 </html>