A JavaScript engine is a computer program that executes JavaScript code. The first JavaScript engines were mere interpreters, but all relevant modern engines utilize just-in-time compilation for improved performance. JavaScript engines are typically developed by web browser vendors, and every major browser has one. In a browser, the JavaScript engine runs in concert with the rendering enginevia the Document Object Model. The use of JavaScript engines is not limited to browsers. For example, the ChromeV8 engine is a core component of the popular Node.js and Deno runtime systems. Since ECMAScript is the standardized specification of JavaScript, ECMAScript engine is another name for these engines.
History
The first JavaScript engine was created by Brendan Eich in 1995 for the Netscape Navigatorweb browser. It was a rudimentary interpreter for the nascent language Eich invented. The first modern JavaScript engine was V8, created by Google for its Chrome browser. V8 debuted as part of Chrome in 2008, and its performance was much better than any prior engine. The key innovation was just-in-time compilation, which can significantly improve execution times. Other browser vendors needed to overhaul their interpreters to compete. Apple developed the Nitro engine for its Safari browser, which had 30% better performance than its predecessor. Mozillaleveraged portions of Nitro to improve its own SpiderMonkey engine. Since 2017, these browsers have added support for WebAssembly. This enables the use of pre-compiled executables for performance-critical portions of page scripts. The JavaScript engines execute WebAssembly code in the same sandbox as regular JavaScript code.
Notable engines
V8 from Google is the most used JavaScript engine. Google Chrome and the many other Chromium-based browsers use it, as do applications built with CEF, Electron, or any other framework that embeds Chromium. Other uses include the Node.js and Deno runtime systems.
SpiderMonkey is developed by Mozilla for use in Firefox and its forks. The GNOME Shell uses it for extension support.
JavaScriptCore is Apple's engine for its Safari browser. Other WebKit-based browsers also use it. KJS from KDE was the starting point for its development.
Chakra is the JavaScript engine of the Internet Explorer browser. It was also forked by Microsoft for the original Edge browser, but Edge was later rebuilt as a Chromium-based browser and thus now uses V8.