JavaScript: Firefox/Aurora 6 and EventSource API

This entry was posted by Rick Waldron (@rwaldron) on May 30, 2011 in EventSource, Firefox, HTML5, JavaScript, jQuery Plugins, Opera, Uncategorized, Web Workers, WebKit and Feature.

I originally wrote this as a comment on Mozilla’s “Aurora 6 Is Here” article - but I’m impatient and couldn’t wait for the comment to be moderated. Also, I haven’t posted in a while and figured Bob the Rooster would appreciate it.

Glad to see support for the EventSource API has made it to Firefox.

There is a major flaw in all existing implementations in that they do not actually open a “listener” for some sort of event that is generated and sent from the server. What has actually been implemented is the equivalent to a native polling mechanism, which is useful none-the-less.

Last fall I released a test supported (unit and spec tests) jQuery extension that provides a unified API (using XHR as fallback).

Additionally, I’ve created these useful EventSource API tests, snippets and demos:

Serializing Array to JSON data:

Echo serialized GET params:

Sending GET params:

I have a number of other gists:

A quickstart guide to EventSource:

An article I wrote about creating EventSource from WebWorker threads:

A mini-web-chat written with EventSource: &

Now that Firefox, Chrome and Opera have implemented the EventSource API, I think it’s a safe and viable addition to our development tool kits.