High-performance JavaScript with GraalVM

Run JavaScript applications faster and more efficiently with GraalVM

Benefits

small footprint advantage icon

Latest JavaScript features

GraalVM is fully compatible with the ECMAScript 2021 specification
improved security advantage icon

High performance on the JVM

Run JavaScript faster using fewer resources
fast startup advantage icon

Node.js support

Run Node.js apps and use packages in Java and other languages
ideal for containers advantage icon

Interoperability with Java

Share data and code with other GraalVM languages like Java, Ruby, Python, LLVM, R, and others
microservices advantage icon

Easy upgrade from Nashorn

GraalVM supports all Nashorn features, improves performance, and includes all the latest ECMAScript features
clouds advantage icon

Advanced tools

JavaScript is supported by GraalVM tools including Insight, VisualVM, Chrome Debugger, VS Code extensions, and others

High Performance

GraalVM Community, GraalVM Enterprise, and V8 Benchmarks Comparison
JavaScript benchmarking
box

There are significant benefits with the GraalJS runtime environment and how that gives SuiteScript developers access to the most current ECMAScript features and syntax out of the box. Aligning SuiteScript with ECMAScript delivers enhanced developer productivity, more maintainable code and ensures ongoing conformance to an evolving standard.

box
Ashwin Krishnamurthy
Senior Product Manager, SuiteCloud Platform

Use Cases

Run JavaScript on GraalVM for optimal performance

JavaScript on GraalVM leverages the Graal compiler to provided unparalleled performance

JavaScript support for OpenJDK

Run GraalVM JavaScript on any OpenJDK distribution

Server-side rendering on the JVM

High performance server-side rendering for React.js and other client frameworks

Run JavaScript on GraalVM Native Image

Embed JavaScript code in Java applications built with GraalVM Native Image

Examples

Java <> JavaScript Interoperability


importorg.graalvm.polyglot.*;

public classExample1Context {
        public staticvoid main(String[] args) {
          System.out.println("[Java] Hello, Java!");
            try (Context context = Context.newBuilder("js").option("js.ecmascript-version", "2020").build()) {
              Value jsFunction = context.eval("js", "" + 
                "(function myJavaScriptFunction(parameter) {         \n" +
                "    console.log('[JS] Hello, ' + parameter + '!');  \n" +
                "    return parameter.toUpperCase();                 \n" +
                "})                                                  \n");

              Value result = jsFunction.execute("JavaScript");
              if (result.isString()) {
                System.out.println("[Java] result: " + result.asString());
              } else {
                System.out.println("[Java] unexpected result type returned from JavaScript");
              }
            }
          }
        }

Using Ruby in Node.js App on GraalVM


import// make sure to install the libraries first: `npm install http ansispan colors` 
public classconst http = require("http");
public classconst span = require("ansispan");
require("colors");
http.createServer(function (request, response) {
  response.writeHead(200, {"Content-Type": "text/html"});
  response.write(span("Hello Graal.js!< br/>".green));
  /start with `node --jvm --polyglot Example2Interop.js` to enable interop with Ruby:
  try {
    response.write("Ruby: " + Polyglot.eval("ruby", "[41,42,43]")[1] + "
");
} catch (ex) { // Polyglot.eval("ruby", ...) failed response.write("Ruby language not found
");
{ response.end("Request completed"); }).listen(8000, function() { console.log("Graal.js server at http://127.0.0.1:8000/".red); }); /* to execute: $ npm install http ansispan colors $ node --jvm --polyglot Example2_Interop.js */

Try GraalVM for JavaScript and Node.js

Connect with us