ndt7-js icon indicating copy to clipboard operation
ndt7-js copied to clipboard

Consider consolidating client to a single minified file with embedded worker code

Open untoldone opened this issue 3 years ago • 0 comments

It might assist developer usability to embed worker code into a single minified file instead of requiring multiple files as per the current documentation. This could be done using URL.createObjectURL and Blob apis. For example:

var downloadWorkerUrl = URL.createObjectURL(
  new Blob([
    '<DOWNLOAD WORKER CODE HERE>'
  ], {type: 'text/javascript'})
);

// which can then be passed to a worker
var worker = new Worker(downloadWorkerUrl)

A scenario where this would be useful is if someone is trying to embed the client in a web-based environment (such as a third party survey tool) where they don't have the ability to upload other static assets to be fetched by the ndt-7 client code. It would also simplify usage in other contexts so that only a single file is needed.

This said, I don't know the client's current browser targets/ these APIs have support for the following:

https://caniuse.com/?search=createobjecturl https://caniuse.com/?search=blob

untoldone avatar Jan 22 '22 00:01 untoldone