File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Qunfeng Wang
Ranch Hand
Posts: 434
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ido Green
author
Greenhorn
Posts: 25
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic