Next: , Up: Web deployment   [Contents][Index]

3.1 Web server setup

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", {});

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>
    <script type="text/javascript" src="/js-runtime/reflect.js"></script>
    <script type="text/javascript" src="/boot.js"></script>
    <h1>Hello, Hoot!</h1>