Remopt
Back to articles

22 June 2026

Where PHP stops and JavaScript starts

PHP builds the page on the server. JavaScript changes it in the browser. The record of a booking belongs on the server.

PHP runs on the server before the page arrives. JavaScript runs in the browser after it arrives.

A page that misbehaves is often a page where the two languages were given each other's job. One runs before the visitor sees anything. The other runs after.

PHP runs before the page arrives. It reads the database, checks the password, and sends HTML. The visitor never sees the PHP file. If the PHP fails, the browser gets an error and nobody gets the form. Saving an order, a booking, or a login belongs here, because this is where the database password stays.

JavaScript runs after the page arrives. It can open a menu, check a field before the form is sent, and change a total without loading a new page. If that script fails, the HTML should still be usable. A menu can be a list of links. A form can still be submitted. A page that is blank until JavaScript runs has made the script do the PHP's job.

WordPress is this split already. PHP sends the pages. JavaScript runs in the editor and in parts of the theme. A custom app can use the same split: PHP for the record, and a small script for the screen.

When a feature needs both, the server decides whether it is allowed, and the browser only shows the result. A total calculated in the browser is a convenience. The total stored with the order is the one PHP wrote.

Need something in this line of work?

Tell me what you need. I reply by email.

Start a project