Neha Patil (Editor)

JavaScript engine

Updated on
Edit
Like
Comment
Share on FacebookTweet on TwitterShare on LinkedInShare on Reddit

A JavaScript engine is a program or interpreter which executes JavaScript code. A JavaScript engine may be a traditional interpreter, or it may utilize just-in-time compilation to bytecode in some manner. Although there are several uses for a JavaScript engine, it is most commonly used in web browsers.

Contents

History

Before the second browser war in 2008-2009, JavaScript engines (also termed JavaScript interpreter or JavaScript implementation) were simply interpreters that read and executed JavaScript source code.

The first JavaScript engine was created by Brendan Eich at Netscape Communications Corporation for the Netscape Navigator web browser. The engine, code named SpiderMonkey, is implemented in C++. It has since been updated (in JavaScript 1.5) to conform to ECMA-262 Edition 3. The Rhino engine, created primarily by Norris Boyd (also at Netscape) is a JavaScript implementation in Java. Like SpiderMonkey, Rhino is ECMA-262 Edition 3 compliant. Applications of the technology include Apple Safari 4's Nitro, Google Chrome's V8 and Mozilla Firefox 3.5's TraceMonkey.

By far the most common host environment for JavaScript is a web browser. Web browsers typically use the public application programming interface (API) to create "host objects" responsible for reflecting the Document Object Model (DOM) into JavaScript.

Performance evolution

A typical major browser has a graphical engine and an independent JavaScript engine, which allows for easier testing, reimplementation or use in other projects. For example, Carakan is used with Presto; Nitro with WebKit; SpiderMonkey with Gecko; KJS with KHTML; Rhino by default has no layout engine. Other combinations are possible, for example, V8 with Blink in Google Chrome. The JavaScript engine gives developers access to functionality (networking, DOM handling, external events, HTML5 video, canvas and data storage) needed to control the web browser.

The JavaScript engine race: 2008 and 2009

During this period there was a race by browser developers to develop even faster JavaScript engines in response to the growing use of JavaScript frameworks and Ajax, as the user's experience is directly influenced by the browser's ability to execute the site's client-side code. In 2008, Google Chrome was praised for its JavaScript performance, but other browsers soon received new JavaScript engines which were faster. Later, Chrome won in the races of better performance. Chrome's strength is its application performance and JavaScript processing speed, both of which were independently verified by multiple websites to be the fastest amongst the major browsers of its time. With the advent of WebKit's Squirrelfish and Mozilla's TraceMonkey JavaScript virtual machines, Chrome's JavaScript execution performance has been found to be slower. Google responded with the Danish-developed V8 which boosted JavaScript performance in Google Chrome 2.

On June 2, 2008, the WebKit development team announced SquirrelFish, a then-new JavaScript engine that vastly improves Safari's speed at interpreting scripts. The engine was one of the new features in Safari 4, released for developers on June 11, 2008; the final JavaScript engine was called Nitro.

In January 2009, the engine then known as SquirrelFish Extreme (SFX) was enabled for Mac OS X on x86-64 architectures as it passes all tests on that platform by Apple Inc. Released June 30, 2009, Firefox 3.5 includes the optimization technique that offered "performance improvements ranging between 20 and 40 times faster" compared to Firefox 3 in some cases.

The JavaScript engine race: 2010

In early 2010, the Norwegian Opera browser replaced the aging Futhark with the faster Carakan, which was 2.5 times faster in early testing. Others in the race, at this time, include Apple's Safari's Nitro (the engine formerly known as SquirrelFish) and Firefox's new JägerMonkey (a "cross-child of Nitro with the older TraceMonkey Engine"). Microsoft lagged behind, lacking a dedicated JavaScript engine and being the slowest of the major browsers. Although by mid-2010, Microsoft held out the carrot of Chakra in then unreleased Internet Explorer 9. JägerMonkey began testing in the publicly released Firefox 4.0 beta in Summer 2010. Safari 5, also released in Summer 2010, featured 30 percent faster JavaScript performance than Safari 4 (using the Nitro engine).

2011

In 2011, Firefox 4 and Internet Explorer 9 were released with their JavaScript software.

Active projects

  • Rhino, managed by the Mozilla Foundation, open source, developed entirely in Java
  • SpiderMonkey, the first JavaScript engine, which powered Netscape Navigator and today powers Firefox
  • V8 - open source, developed by Google in Denmark, part of Google Chrome
  • JavaScriptCore - open source, marketed as Nitro and developed by Apple for Safari
  • KJS - KDE's ECMAScript/JavaScript engine originally developed by Harri Porten for the KDE project's Konqueror web browser
  • Chakra (JScript9), for Internet Explorer
  • Chakra (JavaScript) for Microsoft Edge
  • Nashorn, open source as part of OpenJDK, written by Oracle Java Languages and Tool Group
  • Juce, a C++ application framework, contains a custom embedded interpreter using part of JavaScript's syntax.
  • Inactive projects

  • Tamarin, by Adobe Labs
  • Carakan, by Opera Software, used by Opera web browser version 10.50 until switching to V8 with Opera 14 (released in 2013).
  • Futhark, by Opera Software, used by Opera web browser versions 9.50 to 10.10 until replaced by Carakan in Opera 10.50 (released March 2010).
  • Narcissus open source, written by Brendan Eich, who also wrote SpiderMonkey
  • Implementations

    JavaScript is a dialect of ECMAScript, which is supported in many applications, especially web browsers. Dialects sometimes include extensions to the language, or to the standard library and related application programming interfaces (API) such as the World Wide Web Consortium (W3C) specified Document Object Model (DOM). This means that an application written in one dialect may be incompatible with another, unless the applications are written to use only a common subset of supported features and APIs ("core").

    A dialect and an implementation are distinct: a dialect of a language is a significant variant of that language, while an implementation of a language (or dialect) executes a program written in that language (or dialect).

    References

    JavaScript engine Wikipedia