Created
February 28, 2018 13:56
-
-
Save hemkaran/60f9ed5c956df1d988ba07310f576692 to your computer and use it in GitHub Desktop.
This file demonstrate using web worker to compress the data at frontend side (step 2)
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'}); | |
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