Testing web assembly
Due to some security concerns, modern browsers don't allow running WebAssembly files directly from local directories. If you do try to run them this way, it'll result in CORS or MIME errors.
Some sort of HTTP server has to be set up. There are many possible options, but I'm using PHP on Windows 10:
- Install PHP:
- Download PHP here (version 5.4 or later);
- Set Environment Path variable (restart not needed);
- Run
cmd.exe
and verify success withphp -v
.
- Run
cmd.exe
and navigate to the desired directory (wastest
for this project); - Start the server by
php -S localhost:8000
;- change
localhost
to a preferredIP
, if needed; - change
8000
to a preferred port number, if needed; - stop the server with
Ctrl+C
, when done.
- change
- Open your favorite browser and go to
localhost:8000
.
General order: wat -> wabt -> wasm
WebAssembly text format (.wat
) converted to WebAssembly binary format (.wasm
) using WebAssembly Binary Toolkit.
For now, I'm using an online demo. There is a button Download
on upper-left panel for downloading the binary .wasm
file.
Don't just copy-paste resulting binary data to a text file - it won't work (firstly, the magic number won't match).
You can check the binary with a binary/hex editor. I'm using a free open-sorce hex editor Frhed (portable - doesn't need to be installed).
Free to use and modify for whatever purposes. No copyrights apply.
Work in progress, expect changes...