There is no way to do this, imagine that a malicious user is writing a script that slows down your browser until it is completely inaccessible, now the warning βSlow Scriptβ may come to the rescue, but what if he can intercept it and prevent it show?
You need to find a solution to the main problem, that is, if you are doing a lot of calculations (which, I suppose, you are doing this), you need to break them into pieces, put them in queues and process them either asynchronously (if possible), either ok but with a short timeout between them.
In pseudocode, it might look like this:
var queue = []; // put your functions or the data in here function() processQueue{ if (queue.length > 0) { var item = queue.shift() // pop of the first item of the queue item(); // call the function, or in case of data pass it to th processing function setTimeout(processQueue, 100); // wait 100 ms before processing the next chunck } } setTimeout(processQueue, 0);
source share