Created
February 28, 2018 13:59
-
-
Save hemkaran/73cfe4b5dba4c6d793ab4646ae009de1 to your computer and use it in GitHub Desktop.
This file demonstrate using web worker to compress the data at frontend side (step 3)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.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'}); | |
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. | |
workerInitialized(worker); | |
} 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