Next: JavaScript API reference, Up: Web deployment [Contents][Index]
In order to run Hoot binaries in the browser, a web server needs to host a copy of the Hoot JavaScript runtime.
The runtime files can be found in the
$prefix/share/guile-hoot/js-runtime directory, where
$prefix is the directory where Hoot was installed on your
system. This is typically /usr or /usr/local on Linux
distributions such as Debian, Ubuntu, Fedora, etc.
Don’t forget to upload the Wasm files for the Scheme programs, too!
A bit of JavaScript code is needed to bootstrap a Scheme program using the js-runtime/reflect.js library. For example, here’s an example boot.js file that runs the Scheme program hello.wasm and prints the return values:
window.addEventListener("load", async () => {
const results = await Scheme.load_main("/hello.wasm", {});
console.log(results);
});
The Scheme namespace is defined in reflect.js.
See JavaScript API reference for more information.
To run boot.js on a web page, add <script> tags for it
and reflect.js:
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="/js-runtime/reflect.js"></script>
<script type="text/javascript" src="/boot.js"></script>
</head>
<body>
<h1>Hello, Hoot!</h1>
</body>
</html>