Scripts vs Modules in JavaScript Runtimes

In native JavaScript runtimes, code is executed as either a classic script or an ECMAScript module (ESM). The core difference lies in how the runtime handles scoping, execution behavior, dependency management, and strictness. While classic scripts execute in a shared global context by default, modules provide an isolated file-level scope, enforce strict mode automatically, and allow the use of native import and export statements for modular architecture.

Scoping and the Global Object

Strict Mode

Value of Top-Level this

Import and Export Capabilities

Loading and Execution in Browsers

Execution Frequency (Deduplication)

Runtime Resolution (Node.js)