barcode-reader-wasm

Barcode Reader Wasm

Performance comparison between jsqr and quirc (with wasm) that runs on web worker. For educational purposes.

QR Reader / Scanner jsQR and quirc (C with WASM) through Web Worker

This project is experimental and for educational purpose to see performance of WASM and JS for decode QR Code. Using:

  1. quirc library from C language with Web Assembly
  2. jsQR library using pure javascript
  3. Svelte for UI Framework
  4. Rollup for bundler
  5. Decoder run through Web Worker, it is off main thread!

:warning: Please read

If you see error when using quirc scanner on safari / wasm not properly loaded. It is due to the rollup wasm loader only use WebAssembly.instantiateStreaming() without fallback and not supported on safari. So please use Chrome or other browser instead. :v:

Instalation

install dependencies and devDependencies

$ yarn install

build and start server for development in watch mode

$ yarn dev

Open http://localhost:1001 to see the website

build for production

$ yarn build

build for production and start server

$ yarn build:start

Updating barcode.c code

You need to install emscripten to be able to compile the C code to .wasm format. Learn HERE.

After successfully install emscipten, run this script to compile the C code to wasm.

No optimization

$ yarn build:wasm

Full optimization

$ yarn build:wasm:prod

For optimization explanation, read https://emscripten.org/docs/optimizing/Optimizing-Code.html#how-to-optimize-code

Top categories

Loading Svelte Themes