Using a Barcode Scanner in a Web Browser That Does Not Support WebAssembly

Why might this question arise? This issue is relevant only for very old browsers. Today, all modern browsers support WebAssembly. Although WebAssembly is considered a modern technology, it has actually been around for quite a while. Therefore, there are no real problems with WebAssembly support.

Our DataSymbol Web SDK is delivered with WebAssembly technology by default.

But what should you do if, for some reason, you must use an old browser that does not support WebAssembly?

For this case, we provide a configuration that uses asm.js. What is asm.js? It is a low-level subset of JavaScript that is highly optimized for executing code. Essentially, it is regular JavaScript code that can run in any browser.

At the same time, the entire interface for using our Web SDK remains exactly the same as when using WebAssembly.

The only thing you need to do is include the asm.js library for barcode scanning instead of the WebAssembly version.

This can be done with the following code:

//script selection based on WebAssembly support
var scriptElem = document.createElement("script");
if (typeof WebAssembly === "object")
  scriptElem.src = "datasymbol-sdk-hlp.min.js";
else
  scriptElem.src = "datasymbol-sdk-hlp-asm.min.js";
document.head.appendChild(scriptElem);

Differences between asm.js and WebAssembly:

asm.jsWebAssembly
FormatJavaScriptBinary
SizeLargeSmall
SpeedHighEven higher
LoadingSlowerFaster
SupportLegacyStandard

If you test asm.js and WebAssembly on the same device, you may not notice any visible difference in barcode decoding speed. The only noticeable difference may be the loading time. WebAssembly loads significantly faster.

In reality, situations where you will need to use asm.js are extremely rare. However, if you ever need it, our SDK provides this option.



Ready to get started?

Integrate the DataSymbol Web SDK into your Web application in under an hour. Check out our tutorials, documentation, source code, or download the demo app to get started right away.

Barcode Scanner Web SDK