📄️ Introduction
WebAssembly started as a "JavaScript alternative for browsers". The idea is to safely run high-performance applications compiled from languages like C/C++ or Rust in browsers. In the browser, WebAssembly runs side by side with JavaScript.
📄️ Quickstart for JavaScript
Prerequisites
📄️ Networking
The QuickJS WasmEdge Runtime supports Node.js's http and fetch APIs via the WasmEdge networking socket extension. That enables WasmEdge developers to create HTTP server and client, as well as TCP/IP server and client, applications in JavaScript.
📄️ AI inference
The WasmEdge-QuickJs supports the WasmEdge WASI-NN plug-ins so your JavaScript can run inference on AI models.
📄️ Node.js support
Many existing JavaScript apps use Node.js built-in APIs. To support and reuse these JavaScript apps, we are implementing many Node.JS APIs for WasmEdge QuickJS. The goal is to have unmodified Node.js programs running in WasmEdge QuickJS.
📄️ ES6 Modules
The WasmEdge QuickJS runtime supports ES6 modules. The roll-up commands we used in the React SSR examples convert and bundle CommonJS and NPM modules into ES6 modules to execute in WasmEdge QuickJS. This article will show you how to use the ES6 module in WasmEdge.
📄️ Built-in modules
The WasmEdge QuickJS runtime supports ES6 and NPM modules for application developers. However, those approaches could be more convenient for system developers. They need an easier way to add multiple JavaScript modules and APIs into the runtime without using build tools like rollup.js. The WasmEdge QuickJS modules system allows developers to drop JavaScript files into a modules folder and have the JavaScript functions defined in the files immediately available to all JavaScript programs in the runtime. A good use case for this module's system is to support Node.js APIs in WasmEdge.
📄️ NodeJS and NPM modules
With rollup.js, we can run CommonJS (CJS) and NodeJS (NPM) modules in WasmEdge too.
📄️ Native JS API in Rust
For JavaScript developers, incorporating Rust functions into JavaScript APIs is useful. That enables developers to write programs in "pure JavaScript" yet still use the high-performance Rust functions. You can do precisely that with the WasmEdge Runtime.
📄️ Example: SSR
React is a very popular JavaScript web UI framework. A React application is "compiled" into an HTML and JavaScript static website. The web UI is rendered through the generated JavaScript code. However, executing the complex generated JavaScript entirely in the browser is often too slow and resource consuming to build the interactive HTML DOM objects. React Server Side Rendering (SSR) delegates the JavaScript UI rendering to a server and has the server stream rendered HTML DOM objects to the browser. The WasmEdge JavaScript runtime provides a lightweight and high-performance container to run React SSR functions on edge servers.