13 Using SWI-Prolog in your browser (WASM)

The SWI-Prolog WebAssembly (WASM) port lets you run SWI-Prolog directly in your browser. This is a fairly comprehensive version of SWI-Prolog that supports the core system as well as a good selection of packages, including many of the foreign packages.

The WASM port uses Emscripten to compile the SWI-Prolog source code to WASM, which runs on a virtual machine that is provided by almost all modern browsers.

To build the SWI-Prolog WASM port, see the building instructions on the wiki page


Section Index


13.1 Loading and initializing Prolog
13.1.1 Loading Prolog files
13.2 Calling Prolog from JavaScript
13.2.1 The JavaScript class Query
13.2.2 Translating data between JavaScript and Prolog
13.2.2.1 Translating JavaScript data to Prolog
13.2.2.2 Translating Prolog data to JavaScript
13.3 Accessing JavaScript from Prolog
13.3.1 Asynchronous access to JavaScript from Prolog
13.3.2 JavaScript Promise that can be aborted