Show HN: Chunkify.js – A functional API to unblock your JavaScript thread
yangmillstheory.github.io
yangmillstheory.github.io
People are likely getting their browser tab (perhaps their whole browser) frozen when they click those buttons and having to bail out on your page/submission.
Also, add some overview text instead of a blank page with a ball on it like:
I'll add an explanation of what's happening.
var loop = function() {
for (var i=0; i<1000; i++) {
// do stuff
}
setTimeout(loop, 0);
}
It might not be as fast in some cases, but it works for me.If you mean having the library code "learn" the optimal chunk/delay for a given run, that's possible too, but I'd have to wonder about alternative solutions at that point.
var blob = new Blob([worker_code_string], {type: 'application/javascript'});
var worker_uri = (window.URL || window.webkitURL).createObjectURL(blob);
var worker = new Worker(worker_uri);
The path to the scripts imported with importScript() must be absolute, though. I add the path by modifying worker_code_string. Alternatively they can be fetched and prepended to the code string (or passed in the array of Blob()).Although, depending on task i see cases where chunkify.js will be useful, since i myself used this idea, granted with adhoc implementation instead of using well defined library.