- Demonstrate the use of WebAssembly modules, compiled from Rust, in a simple HTML + JS webpage
- Compare the execution time of WASM and plain JS implementations
- Explore
wasm-bindgen
andjs-sys
crates for Rust-WASM compilation
- Install Rust and
wasm32-unknown-unknown
toolchain withrustup
.
$> rustup target add wasm32-unknown-unknown
- Clone the repository and compile the target which results in a
algo.wasm
module intarget/wasm32-unknown-unknown/release
,
$> git clone https://github.com/shubham0204/WASM-JS-Algorithms
$> cd WASM-JS-Algorithms
$> cargo build --release --target=wasm32-unknown-unknown
- Install
wasm-bindgen-cli
and use it to produce Javascript glue code foralgo.wasm
in theweb
directory.
$> cargo install wasm-bindgen-cli
$> wasm-bindgen --out-dir web --target web --no-typescript target/wasm32-unknown-unknown/release/algos.wasm