Node.js AdvancedLesson 90Free preview
Node WebAssembly
This lesson is part of Node.js · All levels
Summary
This lesson introduces WebAssembly (Wasm) in the Node.js environment: running high-form binary modules compiled from languages such as C/C++ and Rust. Node.js can load .wasm modules through fs and the built-in WebAssembly API. It's useful for speeding up heavy computing or using old C-based libraries.
Key points
- WebAssembly is a binary instruction executed by a JavaScript virtual machine.
- In Node.js a global WebAssembly (instantiate, compile) is available without additional libraries.
- The .wasm module can be loaded from a file with fs.readFileSync and then WebAssembly.instantiate(bytes, imports).
- Wasm runs sandboxed and has no direct access to the file/network without imports.
- Use cases: CPU-intensive algorithms, C/C++ library porting, and cryptography.
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.