JavaScript is the programming language that every major web browser can run. It is what makes a page do things after it loads: open a mobile menu, check a form before it is sent, update a cart total, or power an entire booking app. Despite the name, it has no real connection to Java.
How JavaScript runs in the browser
A page loads JavaScript through a <script> tag. The browser's engine (V8 in Chrome and Edge, SpiderMonkey in Firefox, JavaScriptCore in Safari) compiles and runs it. The code can read and change the page's structure, react to events such as clicks and key presses, and fetch data from servers in the background without reloading the page.
JavaScript runs on a single main thread with an event loop. Long tasks block that thread, which is why a heavy script can make a page feel frozen when someone taps a button. Google measures that responsiveness with Interaction to Next Paint (INP), one of the Core Web Vitals. The language itself is standardised as ECMAScript, with a new edition each year.
Beyond the browser
Since 2009, Node.js has let JavaScript run on servers too, so one language can cover both the page and the backend. TypeScript adds type checking on top and compiles back to plain JavaScript. Libraries such as React are written in it.
An example: a restaurant's table finder
A diner picks a date and party size. JavaScript sends those values to the restaurant's booking service, receives a list of free times, and draws them as buttons on the page, all without a full page reload. Without JavaScript, the same task would need a form submit and a fresh page for every change of date.
How much JavaScript a business site really needs
A brochure site with text, photos and a contact form needs very little JavaScript. Problems start when a page ships far more script than it uses, often through chat widgets, trackers and sliders added over the years. Each one adds download and processing time on cheaper phones. If your site feels sluggish, the script count is one of the first places to look.
Common JavaScript mistakes
- Stacking third-party scripts. Every tag, pixel and widget runs on the visitor's device.
- Hiding key content behind scripts. Text that only appears after JavaScript runs can be indexed late or missed.
- Trusting browser-side checks alone. Visitors can bypass them, so prices and permissions must be checked on the server.
- Ignoring console errors. One uncaught error can stop every script after it.
Related terms
- TypeScript: JavaScript with type checking added.
- Node.js: runs JavaScript outside the browser.
- JavaScript framework: structured toolkits for building apps in it.
- HTML: the page structure scripts read and change.