Updated on Oct 5, 2023
Since Node.js is a runtime environment, which we discussed in a previous part of this tutorial, its primary purpose is to execute JavaScript. We also know that it is single-threaded, and we will add one more element to Node.js’ core: it is non-blocking. That seems like another phrase people just starting off with Node.js may not know what it means. It is actually easy to explain, so read along.
We must first explain what blocking is in the context of Node.js and programming in general. When an application is running, it spawns a process. Then, when it has to execute its JavaScript, it makes a request, or a call, to the server it is hosted on, be it locally on your computer or externally on a provider. Then, the server has to process that request and return the necessary output for the executed script. That is how many programs work: a request is made, then an output is returned. However, where blocking and non-blocking come into play is what happens when the application is waiting for the output by the server. It is relatively simple.
We wanted to introduce you to this vital distinction, as it is one of the most essential features of Node.js. Despite being single-threaded, it can handle all of its processes very efficiently, which attributes to the speed of its applications. The Node.js team has in-depth documentation about the difference if you want to learn more about it.