An Evolution of the Most Widely used Technology in the World.


A collection of components and scripts based on HTML5.


Tutorials and references on the HyperText Markup Language 5.


Tutorials and references on the Javascript language.


Tutorials and references on Cascading Style Sheet.

HTML5 Tags
HTML5 Advance Features

HTML5 Web Workers

HTML5 introduces the concept of Web Workers for running scripts in a thread-like manner. Web Worker scripts can be started in the background and run in parallel to the main HTML page. This allows heavy lifting tasks like number crunching or graphics processing to be carried out without interrupting the main user interface.


The example below shows the use Web Workers in a HTML page. Two Web Workers running the worker.js Javascript are started. The line with "onmessage" defines a function that will be called by the worker script for event notifications. In simple words, it is a mechanism for the web worker to send a message to the main page.

	<!DOCTYPE html>
        <title>Web Workers</title>
        <p>Loop 1: <output id="result1"></output></p>

        <p>Loop 2: <output id="result2"></output></p>


        var worker1 = new Worker('worker.js');
        worker1.onmessage = function (event) {
        document.getElementById('result1').textContent =;

        var worker2 = new Worker('worker.js');
        worker2.onmessage = function (event) {
        document.getElementById('result2').textContent =;


The following shows the code for worker.js. When the "postmessage" function is called, a message is posted back to the function (with the line "onmessage") defined in the main HTML page. The first "for" loop iterates a number from 1 to 1000 and posts back the number to the main HTML page. The second "for" loop does nothing except to cause the first loop to slow down so that it is possible to see the animated running numbers.

        for (var x = 1; x <= 1000; x =x+1)
          for (var y = 1; y <= 1000000; y =y+1)
	        ;//do nothing
The above example can be downloaded below :

Web Workers Example

The World Wide Web and Applications Revolution.

Copyright © 2010-2013 All Rights Reserved.

Valid HTML 4.01 Strict