Sunday, November 13, 2011

A Demo Showing the Performance Benefits of using HTML5 Web Workers

Javscript is fast becoming my favorite programming language and its popularity is only growing as it becomes the core language behind HTML5 based web applications as well as standard web sites.

At my current job, I work with a team that builds the user interfaces for IPTV connected set up boxes (STBs), We primarily use Javascript as the programming language and work on very strict performance oriented code guildlines. i.e As we build code that runs on lower powered hardware like STBs, we need to be very aware of performance when we write code. We monitor CPU and memory performance when we build something and even work hard to shave off a few milliseconds off every feature we code.

But as Javscript is a Single Threaded language there is only so much you can do to really boost performance. We use timers and callbacks to "mimic"  muti threaded behavior but at the end of the day it all runs on a single thread.

Enter HTML 5 Web Workers. This brilliant new addition to Javascript which comes along with the HTML 5 specs really does make Javascript a multi threaded language and takes Javscript development into a whole new arena.

There are fantastic articles on the web on how to use HTML 5Web Workers so I wont go and repeat anything in this post. This article on the HTML5 Rocks site is what I used to build a demo that shows you the very obvious performance benefits of using Web Workers.

> The demo is located here

Instructions on how to run the test are given in the demo page, and I'm sure you will be as surprised as I was when I first ran it myself and saw the results.

Please let me know what you think of HTML5 Web Workers and if you have come across any other good demos.

Happy Coding.

No comments:

Post a Comment

Fork me on GitHub