Times two

No Node? No problem. DCP also supports vanilla JavaScript in the browser.

Here is a minimal example of using DCP in a single HTML file. All script tags encapsulate all the JavaScript code. No module system needed.

First, insert a script element as such to make the DCP Client library visible in order for your job to run. Here, specifying the src as https://scheduler.distributed.computer/dcp-client/dcp-client.js which imports the latest version of the library, but you can also use the path to your dcp-client npm package.

<script src="https://scheduler.distributed.computer/dcp-client/dcp-client.js"></script>

Next, the functions that perform the job contained in another script element.

   * This program doubles numbers in an array
  const { compute } = dcp;
  const $ = document.querySelector.bind(document);
  function workFn(num) {
    return num * 2;

  async function go() {
    const inputSet = [1, 2, 3];
    const job = compute.for(inputSet, workFn);
    job.on('readystatechange', (ev) => console.log(`\nReady State:${ev}`));
    job.on('result', (ev) => {
      console.log(Object.entries(ev).join(' ').replace(/,/g, ': '));
    const resultSet = await job.exec();
    console.log(`results: ${Array.from(resultSet)}`);


Loading an HTML page with these script tags reveals a modal that prompts for a default.keystore. Doing so invokes the go() function which logs distributed results in the console.