Monday, September 22, 2014

On Choosing an AngularJS CDN | Google vs CDNJS

See screenshots below for actual results when retrieving the AngularJS source from the AngularJS CDN.

Methodology
1) using plnkr.co to retrieve the angularjs source, and using a web browser, so the tests will be closely similar to the user's environment,
http://plnkr.co/edit/BDdiRRyvlbKLNftNAfg6?p=preview
http://plnkr.co/edit/ssoeU4ir2pxvilK3FUbg?p=preview

using v1.2.20, below are the two AngularJS CDN used:
//cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.20/angular.min.js
//ajax.googleapis.com/ajax/libs/angularjs/1.2.20/angular.min.js

2) use firefox
- ensure that HTTP status is 200

3) run the plnkr page 5 times for CDNJS and Google's cdn.
- clear cache in between

Google Results
1st try)  365ms
2nd try) 903ms
3rd try) 472ms
4th try) 447ms
5th try) 639ms

CDNJS Results
1st try)  775ms
2nd try) 272ms
3rd try) 269ms
4th try) 252ms
5th try) 247ms

I should use CDNJS, but because I would be deploying with the latest AngularJS (1.3+), including the beta version -- I would use Google's CDN. Because CDNJS doesn't have the latest builds.


Google 

<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.20/angular.min.js"></script>

1st try...

2nd try...
3rd try...
4th try...
5th try...


CDNJS

<script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.20/angular.min.js"></script>

1st try...

2nd try...
3rd try...
4th try...
5th try...