CDN in AngularJS - LearnHowToCode SarkariResult.com Interview Questions and Answers LearnHowToCodeOnline
CDN in AngularJS

CDN in AngularJS

CDN in AngularJS



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

AngularJS Google CDN is available at https://developers.google.com/speed/libraries/#angularjs url. At this url, we can find a snippet something like
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js"></script>
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.
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.min.js"></script>
All the stable versions that is available on Google CDN is written separated by comma under "stable versions:" heading on the google cdn page.

AngularJS cdnjs CDN

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.
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.3/angular.min.js"></script>

Recommended CDN to use

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.

About Mariano

I'm Ethan Mariano a software engineer by profession and reader/writter by passion.I have good understanding and knowledge of AngularJS, Database, javascript, web development, digital marketing and exploring other technologies related to Software development.

0 comments:

Featured post

Political Full Forms List

Acronym Full Form MLA Member of Legislative Assembly RSS Really Simple Syndication, Rashtriya Swayamsevak Sangh UNESCO United Nations E...

Powered by Blogger.