View Full Version : [3.x] ux.Worker/GenericWorker - HTML5 Workers for the masses.

27 Nov 2009, 12:40 PM
Get started using the powerful new HTML5 Worker object.

Developed exclusively for Ext, the Ext.ux.Worker provides an Ext Observable wrapper class around this new threaded object (currently supported on recent versions of FireFox 3.1+, Chrome, and Safari).

What about IE, though? /:)

Fear not, you can deploy HTML5 worker scripts on IE (or other non-HTML5-compliant browser) using the included GenericWorker object (they just won't be truly threaded).
The ux.Worker package assigns
window.Worker = GenericWorker for those browsers that do not support it natively.

What can a Worker do?
Frequently called "Web Workers", these scripted tasks run in a separate thread from the page context that creates them. Compute intensive tasks (heavy loops, number crunching) can be performed in parallel to the renderable portions of your web-page without slowing down the rendering engine. Workers can spawn additional workers to get a complex task done more quickly. Workers can also make XMLHttpRequests (often cross-domain).

Workers are remote-loaded scripts designed to respond to the published event/messaging interfaces which all workers enjoy.

What can't a Worker do?
Workers operate in a protected address space, each with its own global (self) context, and the DOM of hosting browser is off-limits!
There is no window or document object! The only thing they share in common is the navigator and location objects.
Communication between your page and any Worker is accomplished strictly by the use of messaging (postMessage, onmessage, onerror, etc).

What about Google Gears Workers? Can I run HTML5 standards Worker scripts there instead?
Normally, you could not, since Gears Workers support an evolving proprietary API.
But with ux.Workers extension you can run an HTML5 Worker script unmodified as a Gears Worker!

Demo: A live base64-encoding Worker (http://demos.theactivegroup.com/?demo=workers&script=base64-demo).

See/download more at code.google.com (http://code.google.com/p/uxworkers/).

Get used to Workers!
You'll be thinking about using them a lot in future projects. :-?

29 Nov 2009, 9:18 PM
Nice work Doug! I was intrigued when I read about them on Resig's blog but haven't had time to play yet. I was thinking web workers applied inside an Adobe Air application might be a natural fit. Though, I don't think we're quite there yet for Air.