Follow

Should I serve my file myself or via CDN?

With the SDK for the Web, you have two options for how the end customer gets the library.

  1. You can download the file from the npm registry, and serve this file from your servers. 
  2. You can serve the file via CDN. JSdeliver and unpkg are two services that serve all npm packages, including Scandit's.

 

With each approach, there are tradeoffs.

Serving the file yourself means that you have full control over the availability of the library.  Additionally, most CDN services do not offer compression.  Depending on where you self-host things it may be faster because the browser requests the assets from the same server instead of self-hosted-website server + CDN server separately.

Serving the file via CDN allows you to either incorporate the latest library or to specify a version.  We recommend always specifying a version of the library, which means that your application won't be impacted by any changes we make (especially breaking changes).

 

For quick experiments or small demos, using a CDN is perfectly fine and very convenient. However, for production use we strongly recommend self‑hosting the sdc-lib files on your own infrastructure whenever possible. This gives you full control over:

  • performance (caching, compression, latency)
  • availability and resilience (no dependency on public CDN uptime)
  • headers and MIME types for .wasm, .js, .model files
  • exact versioning of the SDK assets

 

When you self‑host, make sure that:

  • libraryLocation in DataCaptureContext.forLicenseKey points to the correct sdc-lib folder URL.
  • The sdc-lib folders you serve match exactly the version of the installed @scandit/web-datacapture-* npm packages.
  • All files from sdc-lib are copied recursively and served with correct MIME types and caching headers.
 

For concrete examples and the latest best practices, please refer to these sections of the documentation:

 

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request