106% Faster - Dynamsoft Barcode Reader v6.5 JavaScript Edition

Mar 21, 2019
106% Faster - Dynamsoft Barcode Reader v6.5 JavaScript Edition

Dynamsoft Barcode Reader v6.5 was just released. Our testing showed phenomenal improvement from the past version, which enabled a much better user experience. We reduced build time by 106% and Improved decoding time by 98%. In this article, we discuss how we achieved these results with WebAssembly optimization and codebase improvement.

Optimizing .wasm Build for a Small Code Footprint

When serving a .wasm file over the network, the smaller the file, the faster the client can download it. Faster .wasm downloads lead to faster page load times, and that leads to happier users. When working with WebAssembly, the process is often to download a module, compile it, instantiate it, and then use whatever it exports in JavaScript. As we discussed, a smaller file size means shorter download time, but faster compilation and initiation also help improve the overall user experience.

Improvements made to v6.5

In v6.5, we employed the following methods to improve the initial library (.wasm) download time for first-time users and faster initialization for returning users at subsequent visits.

  • Source Code Optimization We decreased the amount of C++ source code in the library by embodying the best practices of C++ design when compiled with Emscripten. The result vastly improved barcode decoding performance, as well as and significantly reduced the .wasm file size from 3.4MB to 2.1MB.
  • Further Size Reduction by Compression We also use Binaryen to further reduce the .wasm file size through compression. Binaryen is a compiler and toolchain infrastructure library for WebAssembly, written in C++. It aims to make compiling to WebAssembly easy, fast, and effective. Binaryen’s optimizer has many passes that can improve code significantly. One specific area of focus is on WebAssembly-specific optimizations, which general-purpose compilers might not do. Think of this as WebAssembly minification, similar to minification for JavaScript, CSS, etc., all of which are language-specific.
  • Updated Decoding Algorithms Aside from file size reduction and faster build time, we also updated the JavaScript Edition decoding algorithms to the v6.5 core module algorithms, which improve the following areas:
    1. New 1D barcode verification algorithm to improve the recognition rate
    2. Improved the image-processing performance for blurry PDF417 codes
    3. Improved decoding performance for blurry 1D, QR, and Data Matrix codes
    4. Decreased error recognition rate for Aztec Codes

Try out the new version

Try our online barcode scanning demo Get v6.5 30-day free trial

Subscribe Newsletter

Subscribe to our mailing list to get the monthly update.