Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
This file demonstrate using web worker to compress the data at frontend side (step 3)
url: workerUrl,
dataType: 'text',
success: function (data) {
try {
// Create a blob of the file content, so that we can create blob URL out of it, that can
// be passed to create a web worker file (that runs in the background thread)
var blob = new window.Blob([data], {type: 'text/javascript'});
var workerBlobUrl = window.URL.createObjectURL(blob);
// workerBlobUrl now is the URL to worker file, now we need to create a web worker using this URL.
var worker = new Worker(workerBlobUrl);
// Implemented in the next step.
} catch (e) {
console.log('Error in initializing worker file');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.