Friday, July 20, 2012

AngularJS Now Hosted on Google CDN

As you probably already noticed, one of the core AngularJS values is simplicity. Simple is awesome, but simple and fast is doubly awesome and that's why we also value speed and performance.

Since early beginnings of the project, we strived to make bootstrapping of AngularJS apps as fast as possible and offered to host all of the AngularJS artifacts on our http://code.angularjs.org/ server which follows the best caching and compression practices. Our expertise and server is however no match to the speedy autobahn-like Google CDN (content delivery network).

Thanks to your adoption of AngularJS all over the world, we earned the privilege to be hosted on this state of the art infrastructure. And so I'm happy to share with you, that as of today you can start relying on Google CDN when deploying AngularJS apps.

In order for everyone to truly benefit from this, we need your help. While the CDN definitely speeds up the first download of angular.min.js file (you do use the minified file in production, right?!?). The biggest benefit the CDN will give us is providing the canonical URLs for all common AngularJS files, which are then served with far-future expiration headers and cached in browsers all over the world.

What this means is that if some app (for instance "Spiderman's Todo List") pulls angular.min.js version 1.0.1 from the Google CDN and another app (let's say "Batman's Recipe Book") by an unrelated developer pulls the file from the same url, both of these files will share this file once cached. So if a user uses both of these awesome apps, she will have to download the angular.min.js file only once.

Call to Action

If you run an AngularJS app in production, please instead of hosting the Angular files yourself, change your html file or script loader to use Google CDN urls.

We already approached Plunker and JsFiddle to do the same for their snippet templates. And will work with various teams at Google to use the Google CDN in their apps as well. And of course we are going to switch all *.angularjs.org apps to use the CDN as well.

Google CDN Info

The latest version (v1.0.1) of AngularJS is currently already deployed on the CDN and we'll be adding newer versions as we release them.

The URL for the main angular.min.js file is https://ajax.googleapis.com/ajax/libs/angularjs/1.0.1/angular.min.js

There are additional modules as well as non-minified versions (mainly for development and debugging with Plunker, JsFiddle and similar tools). To see the full list please check out the manifest file.

6 comments:

  1. Any reason why AngularJS 1.1.1 is not on the Google CDN?

    ReplyDelete
    Replies
    1. To my understanding, that's the unstable branch, which is not hosted on the CDN.
      You get that information when clicking the Download button on the AngularJS homepage.

      Delete
  2. I am using version 1.0.7 of AngularJS on the CDN...

    https://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.js

    Is there any way to access the i18n files on the CDN as well? I've tried...

    https://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/i18n/angular-locale_sk-sk.js

    But it doesn't work.

    I can access the manifest of the 1.0.7 release, and it doesn't look like the i18n files are hosted...

    https://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/MANIFEST

    Can we get the next release to include the i18n files on the CDN?

    ReplyDelete
  3. @Jesse, yeah it doesn't look like they're hosting all the plugins just yet :(

    ReplyDelete
  4. When I use the following as CDN
    https://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js

    It also downloads angular.min.js.map.
    How can I avoid that?

    ReplyDelete
  5. Quick update:
    I found the solution for my problem.
    I am using Chrome browser and to solve the problem I had to uncheck the “Enable JS source mappings”.

    ReplyDelete

Note: Only a member of this blog may post a comment.