Sign up ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free.

I looked into minified versions of jQuery and also various online CSS & HTML compression tools. I tried compressing few CSS files and gained only 20-30% compression.

Are these compression tools worth using and do they add considerable performance improvements?

I am looking for tools to compress ASP.NET (.aspx) files.

share|improve this question

closed as off-topic by MichaelT, Bart van Ingen Schenau, durron597, gnat, jwenting Sep 27 at 11:40

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions asking us to recommend a tool, library or favorite off-site resource are off-topic for Programmers as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it." – MichaelT, Bart van Ingen Schenau, durron597, gnat, jwenting
If this question can be reworded to fit the rules in the help center, please edit the question.

Obligatory Coding Horror link:… EDIT: wow... it's over 4.5 years old now. –  StuperUser Jan 3 '12 at 10:52
More modern article: –  StuperUser Jan 3 '12 at 10:56

4 Answers 4

up vote 5 down vote accepted

Minification is a good thing - 20%-30% is actually a very good result. Do you really think that such a reduction is not beneficial? This reduces the amount of data going between your server and any client (a fifth to a third less bandwidth usage!). It means that your server works less and can serve more.

But that is not compression. It is simply removal of unneeded whitespace and renaming of variables to be shorter (an some more tricks like that).

To get the (additional) benefit of compression make sure your server is configured to compress the output with gzip compression.

share|improve this answer
I have Compression enabled in IIS, both static and dynamic, but I don't see much performance improvement. –  RPK Jan 3 '12 at 10:47
@RPK - Well, whitespace and repeated variable names are already getting compressed well with gzip. In this regard, minification doesn't add much. But think about any client that doesn't support gzip compression. –  Oded Jan 3 '12 at 10:49

Always profile before optimization (TM).

I suggest you to look at results of yslow and chrome builtin audits (F12 Audits).

It will tell you what is worth to do to optimize your web site.

share|improve this answer

I think you've got a bit of a conceptual mis-fire here.

"Compression" (you're actually referring to minification) of static assets is a great practice. It saves you valuable bandwidth, as well as increasing the snappiness of page loads for your end users, which is always a good thing.

When you ask for "compression" of .aspx files in this context you misunderstand that the client is not delivered a .aspx file, they are delivered a long string of html, so minifying the .aspx could be completely pointless if you then go and bind a large amount of un-minified html to a control. You'd have to run this process after each page load in order to reap any benefit. However, I think you are asking about this mainly because you have not made the distinction between minification and compression.

Minification of dynamic assets is, generally, a bad thing. You're going to expend more CPU time running the minifier over your generated html page, and you're not going to see much benefit in terms of bandwidth unless your pages are very heavyweight.

What you are most likely to be looking for is actual compression, such as gzip or deflate, which will compress the output of your .aspx. This is actually an IIS setting. This will, again, increase CPU usage, but will (theoretically) provide more of a benefit than simply removing whitespace. Obviously this also applies to static assets, which can be massively reduced in size by the combination of minification and compression.

share|improve this answer
Even though compression is enabled in IIS, I don't see much improvement when using AJAX. I think compression plays only a very limited role when AJAX response itself is slow. Probably, underlying AJAX calls are not well written. –  RPK Jan 5 '12 at 17:52
Again, that's dynamic vs static compression. Plus you need to setup the relevant response type to be compressed in the IIS settings (or machine- or web.config). It really depends on the size of the content you are sending via ajax, I've seen calls that send over 1MB of JSON become MUCH faster once they're done with compression on, but you probably won't see much difference in transfer speed if it's more like 1kb. Also, you're correct, the underlying speed of the AJAX call is something to take into account, just like any normal response time. –  Ed Woodcock Jan 5 '12 at 17:59

Javascript can be minified more than CSS and HTML. In Javascript, variable and function names can be shortened. In CSS and HTML, tag and class names cannot be shortened, because that would give them a different meaning. Minifying CSS or HTML consists mostly of removing whitespace, so this gives limited efficiency.

A common and better way to reduce the size of HTML is to use gzip compression. The server compresses the response and the client decompresses it. This easily results in 80% file size reduction.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.