HTML and CSS Reference
In-Depth Information
After you stop the script, the other func-
tions—such as log() and the timestamp
updater—get a chance to function. Sud-
denly all the information you were expect-
ing appears.
All in all, this is a pretty bad user experi-
ence, and it doesn't even give you the
results you were expecting. Let's look at
what happens when you use a web worker
With a worker, the difference is immedi-
ately obvious—the “Starting” message
appears straight away.
The other noticeable differences are that
the timestamp continues updating and the
browser remains responsive.
Meanwhile, the computation updates are
posted regularly.
To turn the kill_browser() function into a web worker, the first and
most obvious change is that you need to put it in a separate file. You
can then create the worker object from the main page like this:
var worker = new Worker("web-worker-1.js");
Workers don't have access to the DOM ; they can't update elements on
the page or access any global variables in your script. Data has to be
Search WWH ::

Custom Search