mirror of
https://github.com/esimov/pigo-wasm-demos.git
synced 2025-09-26 20:31:20 +08:00
33 lines
977 B
HTML
33 lines
977 B
HTML
<html>
|
|
<head>
|
|
<meta charset="utf-8" />
|
|
<link rel="stylesheet" href="css/style.css" />
|
|
<script src="js/wasm_exec.js"></script>
|
|
<script src="js/stats.min.js"></script>
|
|
<script type="text/javascript">
|
|
function fetchAndInstantiate(url, importObject) {
|
|
return fetch(url).then(response =>
|
|
response.arrayBuffer()
|
|
).then(bytes =>
|
|
WebAssembly.instantiate(bytes, importObject)
|
|
).then(results =>
|
|
results.instance
|
|
);
|
|
}
|
|
var go = new Go();
|
|
var mod = fetchAndInstantiate("lib.wasm", go.importObject);
|
|
window.onload = function () {
|
|
mod.then(function (instance) {
|
|
go.run(instance);
|
|
});
|
|
};
|
|
</script>
|
|
</head>
|
|
<body>
|
|
<script type="text/javascript">
|
|
var stats = new Stats();
|
|
stats.showPanel(1);
|
|
document.body.appendChild(stats.dom);
|
|
</script>
|
|
</body>
|
|
</html> |