Skip to content

Commit

Permalink
Optimize web load by early compilation of the WASM module
Browse files Browse the repository at this point in the history
  • Loading branch information
mbrock committed Apr 27, 2022
1 parent e6b4238 commit a3cdfc0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,8 @@
</style>
<title>Wisp</title>
<div id=wisp-app class=window></div>
<script src=telegram-web-app.js></script>
<script>
wispModule = WebAssembly.compileStreaming(fetch("dist/wisp.wasm"))
</script>
<script type=module src=index.js></script>
<script defer src="https://cdn.auth0.com/js/auth0-spa-js/1.12/auth0-spa-js.production.js"></script>
4 changes: 2 additions & 2 deletions web/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ onload = async () => {
const wasi = new WASI
const wasd = new WASD

const { instance } = await WebAssembly.instantiateStreaming(
fetch("dist/wisp.wasm"), {
const instance = await WebAssembly.instantiate(
await wispModule, {
wasi_snapshot_preview1: wasi.exports(),
dom: wasd.exports(),
}
Expand Down

0 comments on commit a3cdfc0

Please sign in to comment.