I've got a JSONp in Worker. My JSONp content is big enough (about 3MB). For not blocking the UI, I've tried to put the data loading into Worker, to process it there (to minify or something) and return to the main UI thread a lightweight version for further work.
But. Chrome and IE freeze for about 2-3 seconds (in my case) at the moment after they just finished downloading the JSONp. (Even thought that's being done in separate thread).
It freezes even if I put the JSONp loading into a Worker with importScripts (the code below) and even if I do nothing with the data received.
It just feezes the page UI for a few seconds.
Firefox is doing great with all that. So, is there any way I am doing wrong and there is something to handle that issue?
The code is by "standard": Main js:
var myWorker = new Worker('worker-jsonp.js');
myWorker.addEventListener('message', function (e) {
// freezing aldeady took place in here
var data = JSON.parse(e.data);
}, false);
myWorker.postMessage({ url: url, params: params });
The worker:
var myCallback = function (data) {
// the JSONP callback
// the freezing takes place even if I comment the next line (do nothing)
self.postMessage(JSON.stringify(data));
};
self.addEventListener('message', function (e) {
var url = e.data.url;
importScripts(url);
}, false);
Thanks!