JavaScriptWhere JavaScript Runs

Where JavaScript Runs

JavaScript started as a browser-only language. Today it runs in a striking range of environments — and the language itself is the same in each one. What changes is the host environment: the surrounding APIs you can call, and the things you can do with them.

Here is a quick tour of the places you will see JavaScript working.

1. The browser (the original home)

Every modern browser ships a JavaScript engine. Your code runs inside the page and can talk to:

  • The DOM — read and change HTML elements, attributes and text.

  • The BOM (browser object model) — window, location, history, navigator.

  • A long list of Web APIsfetch, localStorage, IndexedDB, geolocation, Web Audio, WebGL, canvas, drag-and-drop, Bluetooth, USB, WebRTC.

Browser: change the page from JavaScript

HTML
<button id="hi">Say hi</button>
<script>
  document.getElementById("hi").addEventListener("click", () => {
    alert("Hello from the browser!");
  });
</script>
2. The server (Node.js, Deno, Bun)

In 2009, Ryan Dahl combined Chrome's V8 engine with a small set of system APIs to create Node.js — a way to run JavaScript outside a browser. That single project moved JavaScript from "browser scripting language" to "general-purpose language" almost overnight.

Today there are three major server runtimes worth knowing:

  • Node.js — the original. Massive ecosystem, default choice for most production work.

  • Deno — built by the same author after lessons learned from Node. Secure by default, TypeScript first-class, browser-compatible APIs.

  • Bun — a much newer runtime focused on speed, with a built-in bundler, test runner and package manager.

Node.js: a tiny web server

JS
import http from "node:http";

const server = http.createServer((req, res) => {
  res.writeHead(200, { "Content-Type": "text/plain" });
  res.end("Hello from Node.js");
});

server.listen(3000, () => console.log("listening on http://localhost:3000"));
3. Desktop applications

A surprisingly large slice of the apps on your computer are written in JavaScript:

  • Electron — bundles Chromium and Node together. Apps such as VS Code, Slack, Discord, Notion, Figma's desktop client, Postman and 1Password use Electron.

  • Tauri — a newer, much smaller alternative. Uses the operating system's native webview, plus a Rust backend.

  • Native Web Components on macOS / Windows — WebView wrappers from each OS that let JavaScript apps run as desktop programs.

The pattern is the same: write a UI in HTML, CSS, and JavaScript; ship it bundled with a runtime so the user does not need a browser to run it.

4. Mobile applications
  • React Native (Facebook) — write your UI in JavaScript with React; render native UI components on iOS and Android.

  • Capacitor / Cordova / Ionic — wrap a web app inside a native shell, plus plugins for camera, geolocation, contacts, etc.

  • Expo — a popular tool-chain around React Native that handles building and deployment.

Apps built this way include parts of Instagram, Discord, Microsoft Office, Coinbase and many smaller products.

5. Edge and serverless

Cloud providers run lightweight JavaScript runtimes close to the user, typically based on V8 isolates rather than full Node processes. A request hits the network, a fresh tiny runtime spins up, runs your handler, returns the response — all in milliseconds.

  • Cloudflare Workers — V8 isolates running in 300+ cities.

  • Vercel / Netlify Edge Functions — same idea, integrated with web frameworks.

  • AWS Lambda@Edge, Lambda Node runtimes, Azure Functions, Google Cloud Functions — serverless Node executions, billed per millisecond.

6. Embedded scripting

Tools that need user-extensibility often embed a JavaScript engine so users can write plugins:

  • Adobe applications (Photoshop, Illustrator, InDesign) accept ExtendScript / JavaScript-based automation.

  • Figma plugins are JavaScript.

  • OBS, Blender add-ons, Unreal Engine plug-ins, and many game engines support JavaScript scripting.

  • Microsoft Office add-ins are JavaScript.

7. IoT and hardware

Even microcontrollers can run JavaScript with engines like Espruino, Moddable XS, Johnny-Five (Node.js over USB) and Tessel. JavaScript is not the lightest choice for tiny hardware, but for prototyping it is fast and accessible.

Same language, different toolboxes

In every environment above, the core language — variables, functions, classes, promises, modules — is identical. What changes is the API around it:

  • In the browser, you get document, window, fetch.

  • In Node.js, you get fs, http, process.

  • On the edge, you usually get the standard fetch API and very little else.

  • On mobile, you get native UI primitives instead of HTML.

Why this matters
When you read a tutorial or library description, look for what *environment* it targets. A snippet that works in Node may not work in the browser if it uses `fs`; a snippet that uses `document` won't work in Node. As you grow as a JavaScript developer you start to recognise which APIs are "language" and which are "environment".