HyperText Markup Language (HTML) documents can contain pieces of programming code, or links to source code files, that are executed at different points while viewing or navigating a web site. These blocks of code generally are referred to as HTML scripts, because they are embedded in the HTML code read by the browser and are executed, at least in part, by the browser; they also are known as client-side script. The most popular HTML scripts are written in a language known as JavaScript®, although it is possible to write HTML scripts in Visual Basic Scripting Edition® and the Tool Command Language (TCL). The purpose of HTML scripts usually is to extend the interactivity of a website by allowing the fast client-side processing of information the user provides, although they also can be used to create visual effects such as animations, games or dynamic graphs. Most often, an HTML script is inserted into an HTML document through the use of the script tag.
There is a technical distinction between HTML scripts and other types of compiled applications or interactive elements that can be used on a website. The script usually is written in a human-readable scripting language and then embedded in an HTML document in some way. Alternately, a web-based application usually is written in a language that requires the code to be compiled in machine code or bytecode that then is executed by a standalone interpreter on the user’s system. Scripts generally are executed by the web browser or a plug-in for the web browser.
Another difference is that HTML scripts tend to be less full-featured than compiled programming languages, relying more on the base functionality of the web browser and HTML for some internal aspects. This makes a script easier and safer to execute in a browser, but also can restrict performance and other features, such as file and hardware access. Some client-side scripts only partially execute inside the web browser, instead contacting the web server to complete execution through other methods. This technique frequently is used for secure or proprietary processing of information, as can be the case on an e-commerce website.
In most instances, HTML scripts are used to access components of a website through the web browser. This allows access to the rendering canvas where the site is drawn, variables such as the background color of a page, or even user events such as mouse movements or button clicks. Complex HTML scripting languages have a structured or object-oriented syntax, allowing the creation of complete applications such as games or word processors. Other times, HTML scripts are used to process data from HTML forms so inputted values are range-checked, converted to other types of data or even formatted for output to a server.