JavaScript is the programming language that runs inside a web page and makes it respond to the person using it. When a menu slides open, a booking form warns that the date is missing or a cart updates its total without reloading, that is JavaScript at work. It sits beside HTML, which holds the content, and CSS, which styles it. Despite the name it has nothing to do with Java, a separate language. For a business owner the point is practical: the same code that makes a page useful also loads your analytics, your advertising pixels and your chat widget, and too much of it is a common reason a site feels slow on a phone in Davao or Iloilo.
In short
- The language that makes web pages interactive.
- Tracking tags and chat widgets are JavaScript too.
- Every script costs download and processing time.
- Google renders it, but with a delay.
What JavaScript does on a page
Most of what a visitor experiences as “the site working” is JavaScript reacting to them. The browser receives the page, then runs the scripts attached to it, and those scripts listen for taps, typing and scrolling.
- Menus and navigation. The phone menu that opens from a small icon.
- Forms. Checking an email address before it is sent, or showing the next question only when it is needed.
- Carts and checkouts. Adding an item, recalculating delivery and handing the payment to a gateway.
- Measurement. Recording a page view or a form sent and passing it to an analytics or advertising platform.
How it fits with HTML and CSS
The three languages divide the work, and the division matters when something breaks. Our page on HTML explains the structure layer, and the page on CSS covers presentation. JavaScript is the layer that changes the page after it has arrived.
That order has a consequence. If the words on a page exist in the HTML from the start, the page can still be read when a script fails or loads slowly. If the words are only added by JavaScript, a broken script can leave a visitor, or a search engine, looking at an empty frame.
The scripts nobody remembers adding
A business site often carries more JavaScript than its owner realises, because much of it comes from outside the build.
- Analytics and advertising tags. Google Analytics, the Meta Pixel and conversion tags are all scripts, often loaded through a Google Tag Manager container.
- Chat and booking widgets. The bubble in the corner is a script loaded from the provider’s server.
- Cookie banners. The consent popup is itself JavaScript, and it decides which other scripts may run.
- Plugins. On WordPress, a single plugin can add several script files to every page, including pages that never use its feature.
- Embeds. Videos, maps and social feeds each bring their own code.
None of these are wrong to have. The trouble is the pile left behind by old campaigns.
What it costs in speed
Every script has to be downloaded, read and run, and on a mid-range phone with a patchy mobile signal that work is noticeable. While the browser is busy running a long script, it cannot respond to the visitor.
This is what Interaction to Next Paint measures, one of the three Core Web Vitals. It records how long a page takes to react visibly after a click, tap or key press. Google’s own guidance rates 200 milliseconds or less as good and more than 500 milliseconds as poor, judged at the 75th percentile of real visits. A page that looks finished but ignores the first tap on its button usually has a script problem.
How Google handles JavaScript
Google describes three stages for pages that rely on JavaScript: crawling, rendering and indexing. Googlebot fetches the page, places it in a queue, and later renders it in an up-to-date version of Chromium to see what the scripts produce. Google notes the wait in that queue can last a few seconds or longer.
Its documentation also sets out a few points worth passing to a developer:
- Links need to be real links. Google finds pages through anchor elements with an href, not through buttons that change the address with a script.
- Content in the HTML is safer. Google calls server-side rendering or pre-rendering a good idea, because it is faster and not every crawler runs JavaScript.
- Missing pages need a real signal. Sites that route pages with JavaScript can show an error message while telling Google everything is fine, which is the fault described on our soft 404 page.
Where it goes wrong
The failures are rarely about the language itself and nearly always about how much of it a site loads and when.
- Tag pile-up. Old campaign pixels still firing on every page.
- Content that depends on a script. Product text or prices that only appear after JavaScript runs.
- Blocking the first screen. Large scripts loaded before the visible content, so the page appears late.
- One plugin per small job. A slider, a popup and a counter, each with its own files.
- Untested changes. A new widget added on the live site that breaks the checkout on one browser.
Words you will hear
- Script. A file or block of JavaScript that a page loads and runs.
- ECMAScript. The formal standard that defines the JavaScript language.
- Rendering. Turning code into the page a browser or crawler actually sees.
- Client-side. Work done in the visitor’s browser rather than on the server.
- Framework. A ready-made code library, such as React, that sites are built on.
- Main thread. The single lane where the browser runs scripts and handles taps.
This week, open your site on a phone, tap the first button you see and note whether it reacts at once. Then ask whoever manages the site for a list of every tag and widget it loads, and which of them are still needed.
Questions we get
More about javascript
What is JavaScript?
Is JavaScript the same as Java?
Does every website use JavaScript?
Can Google read pages built with JavaScript?
Does JavaScript slow a website down?
What does JavaScript have to do with Core Web Vitals?
Do I need to learn JavaScript to run a business website?
Do it yourself
Guides on the same topic
Free step by step guides for owners doing the work themselves. No sign up and no email required.
Related terms
HTML
HTML stands for HyperText Markup Language, the code that gives every web page its structure. What it does, how it works with CSS and JavaScript, and why.
CSS
CSS is the code that controls how a web page looks: colours, fonts, spacing and layout on every screen. What it does next to HTML and how it affects speed.
Core Web Vitals
Core Web Vitals are three measurements Google takes of how a page behaves for real visitors: how fast it appears, how quickly it responds, how much it moves.