aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Web Workers:What are the scenarios to use Web Worker? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Web Workers:What are the scenarios to use Web Worker?" Watch "Web Workers:What are the scenarios to use Web Worker?" New topic
Author

Web Workers:What are the scenarios to use Web Worker?

Qunfeng Wang
Ranch Hand

Joined: Jan 28, 2005
Posts: 433
Web apps would run much better if heavy calculations could be performed in the background, rather than compete with the user interface. With this book, you’ll learn how to use Web Workers to run computationally intensive JavaScript code in a thread parallel to the UI. Yes, multi-threaded programing is complicated, but Web Workers provide a simple API that helps you be productive without the complex algorithms.


I'm quite confused by the book description. It seems the heavy calculations should be done on the server side, not on the browser side. For a responsive UI, what's wrong with the AJAX pattern? So please clarify which scenarios that Web Worker come to a rescue.

Thanks.


To be or not to be. It's a question.
Ido Green
author
Greenhorn

Joined: Jul 27, 2010
Posts: 25
There are many cases where you can't do the heavy calculation on the server side.
There are many reasons why you will want to do them on the client.
Few examples:

* Encoding/decoding a large string that you create on the client and wish to keep it there.
* Code syntax highlighting or other real-time text analysis (like spell checking).
* Background I/O (e.g. Polling web services).
* Complex mathematical calculations (prime numbers, encryption, simulated annealing, etc.) - think on a web app that work offline and still need to run...
* Analyzing or processing video or audio data (including face and voice recognition)
and many more...

Btw, Ajax is great solution in lots of cases but in many situations it will take too much time to pass information (specifically if we talking on large objects) between the client and the server.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Web Workers:What are the scenarios to use Web Worker?