This file demonstrate using web worker to compress the data at frontend side (step 2)
$.ajax({ | |
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'}); | |
workerBlobUrl = window.URL.createObjectURL(blob); | |
// workerBlobUrl now is the URL to worker file, now we need to create a web worker using this URL. | |
} 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