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:
- There is high chance that many of the libs i'm using, are already cached in the user's browser.
- By putting it all in a single
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!)