In previous post, we understood how to setup AngularJS. In this post, we shall learn how to use AngularJS files from CDN (Content Deliver Networks or Content Distribution Networks).
AngularJS Google CDN is available at https://developers.google.com/speed/libraries/#angularjs url. At this url, we can find a snippet something like
In above script tag, we are trying to download the angularjs.min.js file whose version is 1.3.15. To download any newer version of the file that is available on Google CDN, simply replace the version number segment of the url.
For example, to download AngularJS 1.4.2, write following snippet.
All the stable versions that is available on Google CDN is written separated by comma under "stable versions:" heading on the google cdn page.
Like Google CDN, there are few others reliable CDNs that hosts AngularJS files and one of them are cdnjs. AngularJS files can be used from cdnjs at http://cdnjs.com/libraries/angular.js/
In that page, select version number from drop down and copy desired files url to use. AngularJS has many extensions in order to support advance features like routing, animation etc. Those extensions .js files are also available on this CDN. Copy the URL and use it in the <script> block like this.
Apart from above two CDNs there might be many other CDNs hosting AngularJS files, now a but natural question comes in mind, which one to use?
The answer is we should be using most popular CDN available and Google get highest rank in this. As Google CDNs are used by all flavour/ types of developers (Microsoft or Non-Microsoft) so chances are more and more websites will have angularjs files referred from google CDN. In this case AngularJS files of your website may not be loaded from CDN instead from local cache of the end user's browser that improves the performance of your website.Views: 25665 | Post Order: 4