Friday, December 5th, 2008
Ben Turner posted on Web Workers being available in the upcoming beta2 using the latest spec:
First, we’ve moved away from the old Gears-esque API that we had in Alpha 2 (see previous post) in favor of the emerging Web Workers standard. We’ve been hard at work with folks from Google, Apple, and others to get this new spec nailed down.
Most of the missing features I identified in Part 1 have been added with the exception of auto-JSON. There will be a very few small changes between Beta 2 and Firefox 3.1 final (most of which have already landed) and I’ll post about those again once we’re close to shipping.
So what’s available in Beta 2? We currently implement this subset of the Web Workers spec. Very briefly, creating a new worker is as simple as adding the following line to your web page’s script:
var worker = new Worker("workerScript.js");
workerScript.jsfile can do almost anything, really, including using
XMLHttpRequest, importing additonal scripts, spawning new workers, setting timeouts/intervals, and passing complex messages via JSON. Further information can be found in Using DOM Workers.
importScriptsfunction to load Chris’s hosted files rather than having to copy them around. Note that I didn’t bother with very serious error checking so unless you’re using Firefox 3 Beta 2 or newer then it most likely won’t work at all. Check it out here.
It is interesting to crack open the spec an see how it has been updated. It fills really well integrated with other parts of HTML 5. You can share workers cleanly, open a local database directly, show notifications, and import Scripts. Looks really nice.
Posted by Dion Almaer at 10:18 am