Pusher-JS Client 2.2.0 Released

After several months of beta-testing, we’re happy to announce that the stable release of pusher-js 2.2.0 has been published. We didn’t receive any complaints about the last release candidate and our statistics indicate visible improvements in reliability and performance of the library.

We wrote about the changes in previous posts about 2.2.0-rc1 and 2.2.0-rc2, but we wanted to remind you how much better the new version is.

Reduced connection time for HTTP transports

We worked hard on reducing the latency for our HTTP fallbacks. We reduced the number of roundtrips required to establish the connection from 3 to 1, which led to a visible improvement of connection times for many browsers.

New HTTP transport files are also only 15% the size of those from 2.1, improving the latency even more.

Improved connection strategy

By looking at connection logs, we identified several scenarios when the strategy from 2.1 was suboptimal. From 2.2.0, pusher-js will try polling transports in parallel to WebSockets and HTTP streaming. We configured the strategy not to cause additional work for well-behaving clients, but lower the latency for ones behind quirky firewalls.

For clients supporting WebSockets, pusher-js will use encrypted WebSockets as the primary fallback, saving bandwidth and improving connection times.

More reliable dependency loader

In some cases, loading JavaScript dependencies on an unstable network failed and prevented fallbacks from working. In 2.2, the dependency loader has been refactored to retry fetching files and check whether they were loaded successfully.

Extended event binding

Event emitter bind method now takes an optional, third argument – the context of the callback. When passed, the callback will be executed with the passed context. Otherwise, the window object will be used as the context.

Unbinding callbacks is more flexible too – you can remove all listeners bound to a specific context, even if they listen on different events.

The API is documented in the README file.

Various bugfixes

We fixed a few small bugs and leaks. Connection cleanup is more reliable and we’re not assigning to the window.WebSocket property in old Firefox releases.

We also fixed an issue that caused some clients to get into a reconnection loop when using HTTP fallbacks. Now the reconnection logic is much simpler and will not cause excessive traffic.

Upgrading

Upgrading to 2.2 is highly recommended – it has been tested thoroughly and proved itself to be production ready. There are no backwards-incompatible changes, so you don’t need to do anything more than just changing your script tags to point to the newest release:

<script src="http://js.pusher.com/2.2/pusher.min.js"></script>

A big thank you to all the brave volunteers for using 2.2.0 release candidates, contributing to solving early-age problems of the new version. All statistics collected during the beta-testing period were incredibly useful and without them it wouldn’t be possible to notice many of the issues.

Ready to begin?

Start building your realtime experience today.

From in-app chat to realtime graphs and location tracking, you can rely on Pusher to scale to million of users and trillions of messages