There are two fundamental ways of adding scripts to otherwise static web content:
1. You can have the web server execute a script before delivering your page to the user. Such scripts can define what information is sent to the browser for display to the user—for example, by retrieving product prices from the database of an online store, checking a user’s identity credentials before logging her into a private area of the website, or retrieving the contents of an email mailbox. These scripts are generally run at the web server before generating the requested web page and serving it to the user. You won’t be surprised to learn that we refer to this as
2. Alternatively, the scripts themselves, rather than being run on the server, can be delivered to the user’s browser along with the code of the page. Such scripts are then executed by the browser and operate on the page’s already-delivered content. The many functions such scripts can perform include animating page sections, reformatting page layouts, allowing the user to drag-and-drop items within a page, validating user input on forms, redirecting users to other pages, and much more. You have probably already guessed that this is referred to as
client-side scripting, and you’re correct.