Scripts embd in a web page are compil together and execut as part of the web page. Web Workers represent an alternative to this old concept.
Web Workers are an API that allows web developers to separate heavy scripts from the page itself. To clarify: “Web workers” refers to scripts running in the background of a website. They do not have direct access to the content of the page, they can only exchange “messages” with the script that launch them.
Web Workers in action
The script to run in the background of the page must be in the form of a separate javascript file. And it cannot run itself, it must be run by another script via the constructor Worker.
Scripts running in the background of the iran phone number data page are not prevent from communicating with the page. The following script keeps passing more prime numbers to the page through the method postMessa
From the source code samples provid, it is apparent that using Web Workers is plagu by several annoying complications. Mainly, the fact that Workers do not have access to the content of the page and that it is necessary to program the communication between scripts is a reason to think in which cases it is worthwhile to use Web Workers.
Web Workers find real purposeful
use when executing computationally intensive algorithms. Intensive unleashing the power of b2b personalization algorithms to the background, it will be a great relief for users with weaker computers.
If it was an extremely demanding calculation, it could be distribut among several workers. Unlike most other programming languages, JavaScript was design as single-thread due to its multi-platform nature, but with certain modifications in Internet browsers, individual scripts could theoretically be process in parallel by multiple processor cores.
Web Workers can also be beneficial in a variety of unusual cases. For example, if the programmer is not quite sure whether his complex algorithm will not loop under certain circumstances, he can program it as a worker. Then, despite possible looping, you could still work with the page, i.e. the application. The cycle would cycle in the background and not block the user’s activity.
Thanks to Web Workers
each script can bz lists be individually specifi whether it should be execut according to strict mode (new from ECMAScript 5 ) or not.