Introduction to Javascript Engines
Last Updated :
30 May, 2024
JavaScript is a scripting language and is not directly understood by computer but the browsers have inbuilt JavaScript engine which help them to understand and interpret JavaScript codes. These engines help to convert our JavaScript program into computer-understandable language.
A JavaScript engine is a computer program that executes JavaScript code and converts it into computer understandable language.

List of JavaScript Engines:
Browser | Name of Javascript Engine |
Google Chrome | V8 |
Edge (Internet Explorer) | Chakra |
Mozilla Firefox | Spider Monkey |
Safari | Javascript Core Webkit |
Let’s understand each of them.
1. V8: V8 is a JavaScript engine developed by the Chromium Project for Google Chrome and Chromium web browsers. It is a JavaScript engine that can run standalone, or be embedded into any C++ application. Using its own parser, it generates an abstract syntax tree. Then, Ignition generates bytecode from this syntax tree using the internal V8 bytecode format. Bytecode is compiled into machine code by TurboFan. It also handles memory allocation for objects, and garbage collects objects it no longer needs. Optimization techniques such as elision of expensive runtime properties, and inline caching. The garbage collector is a generational incremental collector.
V8 provides an edge as it allows JavaScript to run much faster, which improves users’ experience of the web, paves the way for the development of web applications, and spurs rapid growth of server-side JavaScript through projects like Node.js.
2. Chakra: Chakra is a JScript engine developed by Microsoft. It is proprietary software. It is used in the Internet Explorer web browser. A distinctive feature of the engine is that it JIT compiles scripts on a separate CPU core, parallel to the web browser.

3. Spider Monkey: SpiderMonkey is the first JavaScript engine, written by Brendan Eich at Netscape Communications, later released as open-source and currently maintained by the Mozilla Foundation. It is still used in the Firefox web browser.

4. Webkit: WebKit is developed by Apple and used in its Safari web browser, as well as all iOS web browsers. It is used by the BlackBerry Browser, PlayStation consoles beginning from the PS3, the Tizen mobile operating systems, and a browser included with the Amazon Kindle e-book reader. WebKit’s C++ Application Programming Interface (API) provides a set of classes to display Web content in windows and implements browser features such as following links when clicked by the user, managing a back-forward list, and managing a history of pages recently visited.
Example 1: Executing JavaScript code by using console: For Nashorn engine, Java 8 introduced one new command-line tool i.e.jjl. We have to follow the below steps to execute JavaScript code through the console:
- Create a file named with geeksforgeeks.js.
- Open geeks.js and write following code into the file and save it.
JavaScript
var gfg= function(){
print("Welcome to Geeksforgeeks!!!");
};
gfg();
Output:
Welcome to Geeksforgeeks!!!
Example 2: Executing JavaScript file by embedding JavaScript file into Java code with the help of ScriptEngine class: By the help of the ScriptEngine class, we can create a JavaScript engine and with the JavaScript engine, we can execute the javaScript file.
Java
// Program to show usecase of Javascript
// prog in Java Prog
import javax.script.*;
import java.io.*;
public class Geeksforgeeks {
public static void main(String[] args)
throws Exception {
// Generating Nashorn JavaScript Engine
ScriptEngine ee = new ScriptEngineManager()
.getEngineByName("Nashorn");
// Directly use JS Code inside Java Code
ee.eval("print('Welcome to Geeksforgeeks!!!')");
}
}
Output:

You might get a Runtime Error like
Warning: Nashorn engine is planned to be removed from a future JDK release

This is because Nashorn is going to be replaced by GraalVM.
GraalVM: It is a high-performance runtime that ameliorates application performance and efficiency. It is designed for applications written in various programming languages like Java, JavaScript, LLVM-based languages such as C and C++, and other dynamic languages. It removes the isolation between programming languages and enables interoperability in a shared runtime
Similar Reads
Introduction to JavaScript
JavaScript is a versatile, dynamically typed programming language used for interactive web applications, supporting both client-side and server-side development, and integrating seamlessly with HTML, CSS, and a rich standard library. JavaScript is a single-threaded language that executes one task at
8 min read
JavaScript Function Definitions
JavaScript functions are declared using the function keyword, either as a declaration or expression. Declarations define named functions, while expressions assign functions to variables. Both enable code reuse and modularity. Syntax Function Declarations function functionName( parameters ) { // Stat
3 min read
Introduction to Built-in Data Structures in JavaScript
JavaScript (JS) is the most popular lightweight, interpreted compiled programming language, and might be your first preference for Client-side as well as Server-side developments. Let's see what inbuilt data structures JavaScript offers us: Data Structure Internal Implementation Static or Dynamic Ja
2 min read
What happens inside JavaScript Engine ?
JavaScript is a multi-paradigm prototype-based language, which uses JavaScript Engine such as Chrome's V8 engine Firefox SpiderMonkey engine and etc. They convert the high level code into machine-readable code which lets computer to perform some specific tasks. We will understand this using an image
3 min read
JavaScript Function Examples
A function in JavaScript is a set of statements that perform a specific task. It takes inputs, and performs computation, and produces output. The idea is to put some commonly or repeatedly done tasks together and make a function so that instead of writing the same code again and again for different
3 min read
Interesting Code Snippets in JavaScript
JavaScript is a flexible and powerful programming language that can solve problems in clever and simple ways. Here are some fun JavaScript code snippets that highlight its features and quirks. Whether you're a beginner or an experienced developer, these examples will spark your interest. 1. Flatteni
5 min read
JavaScript Course Interaction With User
Javascript allows us the privilege to which we can interact with the user and respond accordingly. It includes several user-interface functions which help in the interaction. Let's take a look at them one by one. JavaScript Window alert() Method : It simply creates an alert box that may or may not h
2 min read
JavaScript Object Constructors
An object is the collection of related data or functionality in the form of key. These functionalities usually consist of several functions and variables. All JavaScript values are objects except primitives. const GFG = { subject : "programming", language : "JavaScript",}Here, subject and language a
4 min read
How to debug JavaScript File ?
Debugging is essential because there are many errors that are not giving any kind of messages so to find out that we debug the code and find out the missing point. Example 1: Using console.log() Method In this, we can find out the error by consoling the code in various places. Using a console is one
2 min read
How to use Ejs in JavaScript ?
EJS or Embedded Javascript Templating is a templating engine used by Node.js. The template engine helps to create an HTML template with minimal code. Also, it can inject data into the HTML template on the client side and produce the final HTML. Installation StepsInstall the module using the followin
3 min read