Monday, June 20, 2022

JavaScript inside a .NET app

Running JavaScript inside a .NET app with JavaScriptEngineSwitcher

running JavaScript inside a .NET application .. is actually surprisingly easy!

bundle the JavaScript engine inside your library directly.

ClearScript (V8)

The V8 JavaScript engine is what powers Node.JS, Chromium, Chrome, and the latest Edge. The Microsoft.ClearScript package provides a wrapper around the library, providing a C# interface for calling into the V8 library. Just as with ChakraCore, the V8 engine itself is a native dependency. The ClearScript library takes care of the P/Invoke calls, providing a nice C# API, but you still have to make sure you're deploying the correct native libraries based on your target platform.


Jurassic is another .NET implementation of a JavaScript engine, similar to Jint. Also similar to Jint, it supports all of ES5, and it also appears to have partial support for ES6. In contrast to Jint, Jurassic is not an interpreter; it compiles JavaScript into IL, which makes it very fast, and it has no native dependencies!

No comments: