You can run a long job in the background.
Here is a very small library that allows you to do this: http://adambom.imtqy.com/parallel.js/
It also uses all the processing power because it appears on all processor cores in the background.
Sample for setting a long task in the background:
var slowSquare = function (n) { var i = 0; while (++i < n * n) {} return i; };
Example for multi-core:
var p = new Parallel([40, 41, 42]), log = function () { console.log(arguments); }; function fib(n) { return n < 2 ? 1 : fib(n - 1) + fib(n - 2); }; p.map(fib).then(log);
It has a reserve for using timeouts if the browser does not support workers.
Pedro L.
source share