0

I'm writing a web application which conducts calculations that stress the browser and the computer's CPU.

The program should act as follows, and the stressing is not something that is the problem, or needs to be solved.

I would like to prevent the browser (Chrome and Firefox especially) from popping up an error message such as 'page is unresponsive'.

How can I do it using javaScript?

I prefer not to change browser setting (I don't want that users of the app have to change Chrome settings manually).

NightOwl888
  • 55,572
  • 24
  • 139
  • 212
avishle
  • 63
  • 1
  • 9

3 Answers3

0

check this developer tools in Chrome

chrome://chrome-urls/

Go to For Debug

Might help in case of Chrome

Krunal Limbad
  • 1,533
  • 1
  • 12
  • 23
0

Have a look at the Webworkers: https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers

Those run in threads in the background and are designed for heavy load tasks.

0

You should break up the task into pieces if possible (see this question) and delegate out the work to Web Workers.

Using Web Workers is pretty simple, you just specify the URI of the script you want to run (main.js):

var myWorker = new Worker('worker.js');

To communicate with the worker, you pass messages back and forth. To send a message to the worker, call myWorker.postMessage (main.js):

myWorker.postMessage('some value');

To receive messages on the worker, define an onmessage handler like this. You can also postMessage back to the main thread (worker.js):

onmessage = function(e) {
  // e.data === 'some value'
  console.log('Message received from main script');
  postMessage('worker result');
}

Back in your main thread, you can listen for messages from your worker like this (main.js):

myWorker.onmessage = function(e) {
  // e.data === 'worker result'
  console.log('Message received from worker');
}
Ezra Chu
  • 832
  • 4
  • 13