New pusher-js CDN, major improvements

Since the beginning of (Pusher) time, we’ve used CloudFront as the CDN provider for our JavaScript library. Unfortunately, some of the features many of you requested at the time were either difficult, expensive or just impossible to implement on the old platform. Well, we’ve got some good news for you – we have just finished \[…\]

Introduction

Since the beginning of (Pusher) time, we’ve used CloudFront as the CDN provider for our JavaScript library. Unfortunately, some of the features many of you requested at the time were either difficult, expensive or just impossible to implement on the old platform.

Well, we’ve got some good news for you – we have just finished migrating our JavaScript library to our brand new pusher-js CDN with MaxCDN as our new provider, which supports all the requirements we’ve ever been asked about.

There’s a lot better with the new setup – we aren’t kidding when we say this is a big change. Read on for more details about how pusher-js is getting better:

Bandwidth savings with gzip

All our JavaScript files are finally gzipped. This means that you get:

  • 50-60% less bandwidth used to fetch minified files
  • faster page loads
  • improved initial connection time, especially when using HTTP fallbacks
  • better battery usage on mobile devices
  • no extra warnings from PageSpeed

Browsers which don’t want to receive compressed content will be served uncompressed versions of files.

No need for the second domain

Having to switch between HTTP/HTTPS domains is very frustrating, but you can now use js.pusher.com for both encrypted and unencrypted transmissions. Since all major browsers support schema-less URL’s, there’s no need for conditionals:

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

This way browsers will use the same protocol for the document and pusher-js.

Proper CORS support

In order to get better error handling in JavaScript the script tags need to have the crossorigin attribute set. Some libraries (e.g. Polymer) set it for all resources.

In that scenario, modern browsers expect the Access-Control-Allow-Origin response header to contain the origin hostname included in the request. When the Origin request header is missing, the server should set the allowed hostname to *.

While this seems like a simple feature, it’s rarely supported by CDN providers – and now it’s no longer an issue. From now on, js.pusher.com will always return the Access-Control-Allow-Origin header correctly.

What do I need to do?

The only change that requires modifying code is migrating HTTPS requests to the new CDN: if you want to use js.pusher.com with SSL, you’ll need to change URL’s in your applications. Otherwise, you don’t need to do anything – all the changes are already supported by http://js.pusher.com.