toolbox · language

JavaScript

The language behind the shared builder, the games site and Astro's pages.

What it is

JavaScript is the language of the browser and, through Node.js, of our build scripts. It is dynamically typed and runs everywhere without an install step.

How it works

  • Values, functions and objects; async/await for anything that waits on files or the network.
  • Modules split code into files: require in CommonJS, import/export in ESM.
  • In the browser it talks to the DOM; in Node it talks to the filesystem and processes.

In this project

  • shared/build.js reads site folders, fills templates and writes dist/.
  • The games site is plain vanilla JavaScript with no framework.
  • Astro components contain JavaScript between the frontmatter fences, and the interactive parts are ordinary browser JavaScript.

Gotchas

  • "type": "module" in package.json changes .js files from CommonJS to ESM for the whole folder.
  • Browser JavaScript has no filesystem access. Anything that reads files is build-time code.
  • A blank value is not a success: our agents and scripts treat an empty answer as a failure.