views:

62

answers:

3

Is it possible to compress javascript files.... or anything related to a web page before sending it to the client?
i am using telerik controls, and found that their controls write a lot of extra javascript code that makes the page size huge (something around 500KB).

A: 

GZIP, Minification & Packing provided you had access to the .js files. You can do this one-off or programatically before sending it to the client.

Check this out.

http://www.julienlecomte.net/blog/2007/08/13/

Marko
A: 

You can combine and minify your *.js and *.css files with http://github.com/jetheredge/SquishIt/ But I don't know if it can help you to compress telerik's scripts.

Ivan Butsyrin
+2  A: 

If you are using IIS7, it has support for compression built in. Highlight the web application folder (or even the website) in the treeview of IIS manager, in the IIS panel in the next pane select Compression, then in the right hand pane select Open Feature. You then have two checkboxes to enable compression on static and dynamic content.

Be aware though that this may not be the silver bullet - it will increase load on the server, and it will increase the load on the client as the browser as it unzips the content. 500KB is a moderate sized page, but it isn't big. Compression like this is usually only beneficial if it is the network pipe that is the problem, which it seldom is these days. Your issue may be more to do with lots of javascript running during the onload of the page - if you see a reasonable difference in speed between IE7 and IE8 this may be an indication of this problem.

slugster
HTTP compression is available in earlier versions of IIS as well and supported by all browsers.
Panagiotis Kanavos