Facebook Pixel

How Browsers and Node.js Use V8 Differently

Both use V8, but the runtime differs. Here is how browsers and Node.js use the same engine differently.

How Browsers and Node.js Use V8 Differently

Chrome and Node.js both use V8 as their JavaScript engine. But the runtime around V8 is completely different. Here is how they differ.

The Engine Is the Same

V8 is the JS engine in both. It provides:

  • Call stack and heap.
  • Parser, Ignition (interpreter), TurboFan (compiler).
  • Garbage collector (Orinoco).

The Runtime Is Different

FeatureBrowserNode.js
Event loopBrowser-providedlibuv
Global objectwindow / globalThisglobal / globalThis
Async APIsDOM, fetch, setTimeout, localStoragefs, http, crypto, process
RenderingYes (DOM, CSS, paint)No
ModulesES modules (import/export)CommonJS (require) + ES modules
File systemNo (sandboxed)Yes (fs module)
Networkingfetch, XMLHttpRequesthttp, https, net modules
EnvironmentSandboxed (security restrictions)Full system access
Entry point<script> tags or modulesnode file.js

Browser-Specific APIs

  • document, window, navigator, location, history.
  • DOM manipulation (querySelector, createElement, addEventListener).
  • CSS, Canvas, WebGL, Web Audio.
  • localStorage, sessionStorage, IndexedDB, Cookies.
  • alert, confirm, prompt.

Node.js-Specific APIs

  • fs (file system), http/https (server), net/dgram (raw networking).
  • process (argv, env, exit), Buffer (binary data), stream.
  • path, os, crypto, child_process, cluster.
  • require (CommonJS), __dirname, __filename.

Event Loop Differences

  • Browser: renders between macrotasks. Has requestAnimationFrame for visual updates.
  • Node.js: no rendering. Has process.nextTick (runs before promise microtasks) and setImmediate (runs after I/O). libuv's event loop has specific phases (timers, pending callbacks, idle/prepare, poll, check, close callbacks).

Module Systems

  • Browser: ES modules (import/export) are native. Classic scripts use <script> tags.
  • Node.js: CommonJS (require/module.exports) was the original. ES modules are supported with .mjs or "type": "module" in package.json.

The Takeaway

Chrome and Node.js share the same V8 engine, but the runtime is different. Browsers provide DOM, rendering, and Web APIs. Node.js provides file system, networking, and system-level APIs. The event loop is browser-provided vs libuv. Modules are ES modules vs CommonJS. Understanding both runtimes makes you a better full-stack developer.

Yes. Both use V8. The engine (call stack, heap, parser, compiler, GC) is the same. But the runtime around V8 is different: browsers provide DOM, rendering, and Web APIs; Node.js provides file system, networking, and system-level APIs.

The browser event loop renders between macrotasks and has requestAnimationFrame. Node.js uses libuv's event loop with specific phases (timers, poll, check, close) and has process.nextTick (runs before promise microtasks) and setImmediate. No rendering in Node.js.

fs (file system), http/https (server), net/dgram (raw networking), process (argv, env, exit), Buffer (binary data), stream, path, os, crypto, child_process, cluster. These give Node.js full system access.

document, window, navigator, location, history, DOM manipulation, CSS, Canvas, WebGL, Web Audio, localStorage, sessionStorage, IndexedDB, Cookies, alert, confirm, prompt. These are for building web UIs.

Node.js originally used CommonJS (require/module.exports). ES modules (import/export) are supported with .mjs or 'type': 'module' in package.json. Browsers use ES modules natively (import/export) with <script type='module'> or classic scripts with <script>.

Ready to master React completely?

Want to upskill yourself, crack your next interview, and get your dream job? Join our comprehensive course to dive deeper with high-quality video tutorials, solve interview questions, and a premium community.

Please Login.
Please Login.
Please Login.
Please Login.