Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

communitycreator
javascript
webassembly

How to use WebAssembly with Javascript

Adodoola Omiyale

WebAssembly

WebAssembly acts as a compilation target for other languages, such as C++ and Rust, to run on web applications. Using WebAssembly, developers can execute code in multiple languages other than javascript to create complex web applications such as video games and 3D rendering at near-native speed.

A compilation target takes input in one language and produces an output in another.

WebAssembly and Javascript

WebAssembly acts as a complementary addition used to improve the functionality of javascript execution on web browsers.

WebAssembly illustration
  • Stage 1: A high-level language, such as C++ is the input language.
  • Stage 2 and 3: The C++ code will be compiled into a set of instructions, which is called a WebAssmembly module. This module will be delivered in a binary format, stored in a .wasm file.
  • Stage 4: The .wasm file is turned into machine code and executed in the browser.

Benefits:

  • Speed and performance: Compared to the javascript process, the module code optimization happens far earlier in the code compilation process before reaching the browser.
  • Security: Following browser security policies, model execution is executed in the same sandboxed environment as Javascript.

RELATED TAGS

communitycreator
javascript
webassembly
RELATED COURSES

View all Courses

Keep Exploring