Posts

Showing posts from February, 2026

Browser vs Node.js Runtime

Browser Runtime: // Available in browser window.alert('Hello'); document.getElementById('button'); localStorage.setItem('key', 'value'); fetch('https://api.example.com'); // NOT available in browser const fs = require('fs'); // ERROR!   Node.js Runtime:  // Available in Node.js const fs = require('fs'); const http = require('http'); process.exit(0); // NOT available in Node.js window.alert('Hello'); // ERROR! document.getElementById('button'); // ERROR!  What Does "Providing a Runtime" Mean? When we say "Node.js provides a runtime for JavaScript," we mean: It gives JavaScript a place to run outside the browser It provides access to system resources (files, network, processes) It manages memory and execution It handles errors and crashes It provides utility functions and modules Real-World Example When you run Playwright tests: // Your test file: test.js const { chromium } = requi...

what is Node.js runtime environment?

  What is a Runtime Environment? A runtime environment is the infrastructure that allows your code to execute. Think of it as the "world" where your program lives and runs. Simple analogy : Your JavaScript code = a recipe Runtime environment = the kitchen with all the tools, ingredients, and appliances needed to make that recipe The Node.js runtime environment is everything that's needed to execute JavaScript code outside of a browser. It includes: 1. JavaScript Engine (V8) Reads and executes your JavaScript code Converts JavaScript to machine code the computer understands Same engine Chrome uses 2. Core Libraries/APIs Built-in modules that give JavaScript superpowers it doesn't have in browsers: // File system access (not possible in browsers!) const fs = require('fs'); fs.readFile('data.txt', 'utf8', (err, data) => {   console.log(data); }); // HTTP server (create your own web server!) const http = require('http'); http.cr...

Why do we need Node.js as a pre-requisite before installing Playwright?

Before we get into the details, let us first know the origin of Node.js Ryan Dahl created Node.js in 2009 . He was a software engineer frustrated with the limitations of existing web servers at the time. The Problem He Wanted to Solve In 2009, Ryan was working on web applications and noticed: Apache HTTP Server (the most popular web server) handled each connection with a separate thread This meant if you had 10,000 simultaneous users, you needed 10,000 threads Creating/managing so many threads consumed massive memory and CPU File upload progress bars were difficult - servers couldn't easily tell the browser "50% uploaded... 75% uploaded..." By combining JavaScript, V8, and non-blocking I/O, Ryan Dahl created a platform that revolutionized backend development and enabled JavaScript to dominate both frontend and backend.   Playwright is Built on Node.js Playwright is a Node.js Library Playwright is written in TypeScript/JavaScript and distributed as an npm package It r...