Last week, somebody asked the following question in the Scrimba Discord server: Is there a good way to read a text file in vanilla JavaScript? All solutions that I find online seem to use some variant of Node. The question suggests that JavaScript code written for Node.js is not vanilla JS. This is an understandable misconception.

Vanilla JS

“Vanilla JS” is JavaScript code written without any frameworks or libraries. It’s written only with the features that are defined by the ECMAScript language specification and the JavaScript runtime environment. Some developers scoff at the idea of writing vanilla JS, but it has its merits. If you count yourself among these developers, I encourage you to check out The Lean Web.

ECMAScript

JavaScript is based on the ECMAScript language specification. The organization in charge of this specification is called Ecma International. The purpose of the specification is to ensure a standard implementation of JavaScript that works across runtime environments. It specifies how JavaScript engines should implement core language features such as primitive values and objects.

Runtime environment

In computer programming, a runtime environment is an environment that provides the functionality necessary for a program to run. We use runtime environments because high-level programming languages such as JavaScript cannot run directly on a computer’s hardware. This is true even of a compiled language like Java, whose compiled bytecode is run on a Java virtual machine. Web browsers are the most common JavaScript runtime environment. Node.js is the most common outside the browser, although there are others such as Deno and Bun.

APIs

An application programming interface (API) is an intermediary that lets two applications communicate. The ECMAScript language specification does not include any input/output (I/O) such as networking, storage, or graphics facilities. The JavaScript runtime environment provides APIs for this purpose.

Web APIs

Popular Web APIs include (but are not limited to):

Node.js APIs

Popular Node.js APIs include (but are not limited to):

Summary

If JavaScript code is written only with features defined by the ECMAScript language specification and the JavaScript runtime environment, it can be considered “vanilla JS”. The runtime environment is irrelevant, although different runtimes may provide different APIs for input/output (I/O).

I informed the member of the Discord server that the File System (fs) API is provided by the Node.js runtime environment, which is why they kept finding Node.js solutions. Judging by the wording of their question, they were looking for a Web API. I pointed them to the File System Web API.