Skip to content
amvtek edited this page May 15, 2014 · 9 revisions

EventSource (aka Server Sent Event) is a javascript api part of the html5 suite, which let you process datas sent asynchronously over a single HTTP connection. EventSource objects connect to a web server and allow registering handler functions that will be called back when a new message has been received...

Quickstart

Distribute the eventsource polyfill file with your website javascript.

From here, in webpages where you need to maintain EventSource connections ensure that the polyfill has been loaded prior you instantiate the EventSource you need...

The EventSource polyfill class will be used in cases where the browser does not support the Server Sent Event api.

There are a few pecularities you should be aware off when using this polyfill especially if you are planning to support IE8+ browsers.

For more informations, refers to the project User Guide .

Goals

One problem with the EventSource api is that it is not yet consistently supported accross browsers. The caniuse website report shows that support in Internet explorer and Android browsers is currently problematic.

After having tried several polyfills aiming at providing a fallback implementation of the API in browsers where it is not available, we realized that available options were restrictive regarding the browsers they are allowing to support and not sufficiently tested.

The aim of this project is to provide a well tested and reasonably documented polyfill implementation aiming at providing EventSource in browsers that matters today.

Context

We are using the eventsource polyfill exported by this project in the context of a large scale realtime monitoring system. In this system, users may access web pages that let them vizualize evolution of datas coming from a large collection of sensors.

We initially used a long polling approach to update the data vizualization web pages in near realtime. This worked pretty well for cases where the data update rate was a few messages per minutes. But where the update rate started to approach 10-100 messages per seconds, the server side load and client side performance started to be problematic.

Moving to EventSource helped us deliver a simpler and more scalable system.

Clone this wiki locally