The Long Journey of Server-Sent Events (EventSource)

Over six years ago Ian Hickson wrote up a proposal for Server-sent DOM events. This feature allowed for creating a persistent connection with the server over HTTP and let it stream updates to the page as DOM events. News tickers, stock updates, and all kinds of other use cases would be a lot easier to implement. It became part of something that is now known as HTML5 and we prototyped an implementation and shipped it in Opera 9.

The specification however was really quite complex and our implementation not entirely complete. Based on feedback from Jonas Sicking the feature was redesigned to no longer be based on an element, but rather a simple object — much like XMLHttpRequest. Feedback before that had already drastically simplified the event stream format so no longer each and every feature of a DOM event had to be supported. The EventSource object also moved out of HTML5 into its own Server-Sent Events specification.

When WebKit gained an implementation of this feature we thought we should update our experimental version so less special casing by developers would be needed. I wrote a test suite for EventSource and Pablo Flouret then went to update our implementation which resulted in quite a bit of code removal :hat: (We love code removal.) Our work can be found in the latest Opera 10.70 snapshot and will most certainly make it into Opera 10.70 final as well. The test suite will be contributed to the W3C WebApps WG and has already been shared with WebKit developers.

Now we have two implementations — i.e. one in Opera and one in WebKit — that are very close to each other and six years of experience with the feature, the Server-Sent Events specification can finally become a standard. :beer: