mirror of
https://github.com/nlepage/go-wasm-http-server.git
synced 2026-01-12 01:59:14 +00:00
⚗️
This commit is contained in:
@@ -20,22 +20,7 @@
|
||||
<label for="name">Name : </label><input id="name" value="World">
|
||||
<button onclick="hello()">Hello</button>
|
||||
<script>
|
||||
const startWasm = async (wasm, { scope, base = '' } = {}) => {
|
||||
try {
|
||||
const options = {}
|
||||
if (scope) options.scope = scope
|
||||
const registration = await navigator.serviceWorker.register('sw.js', options)
|
||||
await navigator.serviceWorker.ready
|
||||
registration.active.postMessage({
|
||||
type: 'startWasm',
|
||||
wasm,
|
||||
base,
|
||||
})
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
}
|
||||
}
|
||||
startWasm('api.wasm')
|
||||
wasmhttp.register('api.wasm', { base: 'api' })
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user