You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
681 B
35 lines
681 B
<!doctype html> |
|
|
|
<html> |
|
|
|
<head> |
|
<meta charset="utf-8"> |
|
<title>WASM test with XHR</title> |
|
</head> |
|
|
|
<body> |
|
<script> |
|
const importObject = { |
|
my_namespace: { |
|
imported_func: arg => { |
|
console.log(arg); |
|
} |
|
} |
|
}; |
|
|
|
const request = new XMLHttpRequest(); |
|
request.open("GET", "rats.wasm"); |
|
request.responseType = "arraybuffer"; |
|
request.send(); |
|
|
|
request.onload = () => { |
|
const bytes = request.response; |
|
WebAssembly.instantiate(bytes, importObject) |
|
.then(obj => { |
|
obj.instance.exports.exported_func(); |
|
}); |
|
}; |
|
</script> |
|
</body> |
|
|
|
</html>
|
|
|