CDN (Content Delivery Network) are distribuited servers across the internet that server your site not only with redundancy, but througth the nearest way to your end client.
This service is used for large websites and companies. But we can use part of these services for free and speed up our sites and apps. Let's learn why.
! This is an old article (2013). Maybe the content is outdated.
Some thougths and rules about performance
We have also a few limitations to face it. The number of simultaneos connections per browser (browser max connections) vary a lot, starting from 2 up to 60, and servers can limit that parameter too. We also know that if we could spread our request through many servers, our page would be faster.
And there's another detail to think about: if we use a static resource that our cliente already used, it would be in its cache (and/or proxy) - and, yeah, the page would appeared even faster!
Now we are on the real development dilema, how to start our HTML page with max perfomance and low effort.
What we use on real development
A simple page for using Twitter Bootstrap would look like the following:
Yes, a quite simple start.
Converting to CDN
More and more assets on CDN
Not all of our needs have their own CDNs. But, fortunately, two great services provide CDN for a lot of great tools:
You can search and choose the right version to use in your app. underscore.js can be include with:
Too much CDNs references can be bad
CDNs are very usefull. But if you include too much resources, you can have the side effect for breaking the rule "too much requests". Maybe part of the assets can be combine localy. Use Yuy Compressor or JSMin.
Make some tests mixing both technics to find the optimal for your application.
Other CDN sources
Which of them must we use? This article makes a good comparision.
A great use for CDNs are quick bootstraping. One file (or template, depending on your development method) and you can start your project, already up to date with best practices.
Another advantage is the simple updating of libraries: just change the version on your template and it's done. Even downgrade is easy.
No more excuses to use CDN in your projects!