The programs in this language are called scripts. They can be written right in the HTML and execute automatically as the page loads.
Scripts are provided and executed as a plain text. They don’t need a special preparation or a compilation to run.
Different engines have different “codenames”, for example:
- V8 – in Chrome and Opera.
- Gecko – in Firefox.
- …There are other codenames like “Trident”, “Chakra” for different versions of IE, “ChakraCore” for Microsoft Edge, “Nitro” and “SquirrelFish” for Safari etc.
These terms above are good to remember, because they are used in developer articles in the internet. We’ll use them too. For instance, if “a feature X is supported by V8”, then it probably works in Chrome and Opera.
Engines are complicated. But the basics are easy.
- The engine (embedded if it’s a browser) reads the script (“parses”) and converts (“compiles”) it to the machine language.
- And then it runs, pretty fast.
The engine applies optimizations on every stage of the process. It even watches the script as it runs, analyzes the data which flows through it and applies optimizations to the machine-code basing on that knowledge.
- Add new HTML to the page, change the existing content, modify styles.
- React on user actions, run on mouse clicks, pointer movements, key presses.
- Send requests over the network to remote servers, download and upload files (so-called AJAX and COMET technologies).
- Get and set cookies, ask questions to the visitor, show messages.
- Remember the data on the browser side (“local storage”).
The examples of such restrictions are:
Modern browsers allow it to work with files, but the access is limited and only provided if the user does certain actions, like “dropping” a file into a browser window or selecting it via an
The limitation is again for user’s safety. A page from
http://anysite.comwhich a user has opened occasionaly must not be able to open or access another browser tab with the URL
http://gmail.comand steal information from there.
- Full integration with HTML/CSS.
- Simple things done simply.
- Supported by all major browsers and enabled by default.
While planning to learn a new technology, it’s beneficial to check its perspectives. So let’s move on to the modern trends that include new languages and browser abilities.
That’s normal, because projects and requirements are different for everyone.
The modern tools make the transpilation very fast and transparent, actually allowing developers to code in another language, autoconverting it “under the hood”.
Examples of such languages:
- TypeScript is concentrated on adding “strict data typing”, to simplify development and support of complex systems. It is developed by Microsoft.