By spending long hours looking for how to start, I can finally run my compiled C function on web browser
Nothing to do with them. Just try to create more C functions and see its performance.
It is also possible for other programming languages such as C++, TypeScript, Rust, etc. However, it might not work for my case.
- Create
C
files in/wasm
directory.
Note: that the file name and function name must be the same - Run my custom script
npm run compilec
.
Note: you need to install compiler from webassembly offical website - The script will create
.wasm
file and.js
file in the same directory - Fetch the wasm file in html script
- Set function to
window
instance - Call the function
- Run
http-server
to host it.
Note: you might need to runnpm install -g http-server