This question tries to find whether its worth to trade-off the benefits of a CDN in favor of a more structured and organized vendor code management.
I know that using a CDN to deliver vendor libs like jquery is recommended.
Yet, I was reading about bower today and It made me wonder. With bower I can easily manage all of the dependencies of my application in a very structured way. I can eventually pack them up in a single vendor.js
file (using yeoman, brunch or simple grunt) that will be server in the html in a script
tag.
However, while this approach can make my life easier, what are its cons? I can think of the following:
vendor.js
file, the browser will eventually cache this file, but I will start facing problems whenever I add new third-party depencies, ie when my vendor file is changed. The browser will have to reload that file (thus loosing the caching of the original vendor.sj file)Putting it this way, paying the time to manage dependencies in the html as <script>
tags, seams to offer a better performance/load time.
Do you think there is something wrong in my way of thinking? Is the benefit of organizing code with say bower
, convincing enough? After all, its like for backbone. Yes a backbone app is heavier for small applications, it contains more code.. but from a dev point of view, its worth it!
Cheers (and thanks for the comments that made me re-edit the question!)
Anybody who has a website or mobile application that's likely to be requested by more than one user at a time can benefit from a CDN. They are especially useful to large, complex websites with users spread across the globe, and websites or mobile apps with lots of dynamic content.
Traditional web hosting relies on one server, while a CDN leverages a worldwide network of edge servers that disseminate content from a variety of interconnected hosts. The last difference is in the amount of content each option delivers.
Keep in mind that a CDN is necessary if your company fits in with only one of the points. You should seriously consider a CDN if: Your site is growing at an exponential rate – A regular server is going to have a tough time handling a spike in traffic, unless you prepare for it with a CDN.
Use a CDN when it is available to you and is allowed by your project's requirements. It is generally faster, and browsers will have likely cached those files from other sites already.
Most sites I build, I use jQuery from the CDN. However, you will find that sometimes those CDNs are blocked by specific countries. In any case, it doesn't hurt to have a fallback. You can load jQuery from a CDN, and fallback to your own server if that fails.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With