Sunday, December 5, 2010

Two simple steps to reduce bandwidth on static files

First step is to let Google host your JavaScript library of choice for you. Google Libraries API hosts JQuery, Mootools, Prototype... and you can directly link to them from your website.

More info at:

Second step is to compress you CSS file (or files, but if you are gonna compress it to save bandwidth, probably you want to merge them in one for better performance). There are several websites which compress CSS files online, and for free. The one I found which works best is:


  1. Well, IMHO it is not *that* good to link js/css/whatever static files directly on google. What if they just change the file and you didn't notice? what if they just move the file and rename it or simply stop offering that solution?

    What if someone hacks into one of the google servers and replace the file with some malicious js code?

    If any of those things ever happen you will find that all the sites/apps you've linked against google static files will be in trouble.

    I think a much better approach would be set up a small (set of) server(s) running something like varnish-cache, squid or even one of those new webservers (like nginx or cherokee) to serve your static files. Fast, secure and reliable.

  2. I'm not talking about linking files from Google, I'm talking about using the Google Libraries API, where Google maintains versions of jquery (among others) for the use of the community.

    They have a commitment to maintain the versions they upload there. And to be honest, if someones hacks Google, my jquery file will be the last of my concerns.