开发者

What are the best HTML+CSS compression methods?

I have an ASP.NET web application and I'm thinking about the following: before sending any HTML or CSS content to users, I wish to 'compress' them, then cache the result and send that to the clients.

I know it is possible to compress these by removing whitespaces, comments and stuff like that, but I'm not really familiar with more advanced solutions for this.

  • Apart from this, what compression methods are there and what are the advantages of each of them?
  • Does some browsers or the HTTP protocol itself support any kind of compression?

EDIT: I'm intereste开发者_StackOverflowd in doing this to dynamically-generated HTML, too.


gzip is most commonly used for "advanced" compression (i.e., not just removing whitespace). It is supported by all the major browsers: http://www.gzip.org/. It uses the DEFLATE algorithm. If you only want to minify your files, try:

  • http://www.cssdrive.com/index.php/main/csscompressor/ for CSS
  • http://fmarcia.info/jsmin/test.html for JS

Or try YUI Compressor or any of the other popular ones.


You can look into any of the minify methods offered by google, yahoo, microsoft for your javascript and css. They all do a good job. Check out this article for tests on all three.

Additionally, you can have IIS gzip compress all your content and even cache it (look at the http headers tab for caching).

Have a look at this article for some other ways to speed up your web app also.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜