add.html 453 B

1234567891011121314151617181920
  1. <!DOCTYPE html>
  2. <!-- add.html -->
  3. <html>
  4. <head>
  5. <meta charset="utf-8">
  6. <title>WASM test</title>
  7. </head>
  8. <body>
  9. <script type="module">
  10. (async() => {
  11. const response = await fetch('add.wasm');
  12. const bytes = await response.arrayBuffer();
  13. const { instance } = await WebAssembly.instantiate(bytes);
  14. console.log('The answer is: ' + instance.exports.add(1, 2));
  15. })();
  16. </script>
  17. </body>
  18. </html>