Some rants about technology, PHP, people, tools, web etc from a developers perspective. Feel free to copy ideas, code or anything from here.

Monday, January 14, 2008

Minify JS and CSS

1 comment
So you just finished working on your new shiny web 2.0 application/site. It all looks very good until you open it on your friends computer to show off your baby. Its painfully slow!!. Hmm you must be wondering why its taking so much time to load.

The answer may be revealed to you once you see the source of your page. Its all good and dandy that you are using the "mini" version of Javascript frameworks like prototype, jquery, YUI etc. Whats probably slowing down your page is the sheer number of JS and CSS files you are loading on your page.

To mitigate the impact of so many files being loaded in your page you can use this novel idea. Look at this URL for more info. http://code.google.com/p/minify/ Minify.


What minif does is that it lets you load multiple JS and CSS files with one single call. It even caches the file generated so that subsequent requests don't have the overhead of "php" processing. I had some spectacular results with this approach where the sheer number of requests was taking a toll on the page.

1 comment :

Martin said...

Thanks a lot!