views:

280

answers:

5

What're the best practices for CSS/HTML minimizing? I'm looking for server side tools to fasten the interaction with the browser.

+1  A: 

GZip compression is pretty standard and does a great job.

Ryan
Can you give me a hint as to how I add it to my project?
konzepz
depends on what you're using for a setup- but here is some general knowledge and setup of it. http://betterexplained.com/articles/how-to-optimize-your-site-with-gzip-compression/
Ryan
+2  A: 

Take a look at YUI Compressor

Ilya Biryukov
Thanks. Looks like the right direction.
konzepz
+1  A: 

Minifying css and javascript can help. Using css sprites for graphic images like backgounds, icons and such reduce the number of requests to the server.

Tomsky
Thanks. Already using CSS sprites. I was referring to the code itself.
konzepz
+4  A: 

The single best tool is probably server-side compression. You can enable this globally in Apache using mod_deflate. Just make sure mod_deflate is loaded, and stick this in the bottom of your httpd.conf file:

# mod_deflate for server-wide output compression.

SetOutputFilter DEFLATE
# Netscape 4.x has some problems...
BrowserMatch ^Mozilla/4 gzip-only-text/html
# Netscape 4.06-4.08 have some more problems
BrowserMatch ^Mozilla/4\.0[678] no-gzip
# MSIE masquerades as Netscape, but it is fine
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
# Don't compress images
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary
# Make sure proxies don't deliver the wrong content
#Header append Vary User-Agent env=!dont-vary

All static and dynamic content will then be served compressed to browsers that support it.

Other modern web servers will support this as well I'm sure, you'd just have to take a look at their docs to find out how to enable it.

zombat
That's *exactly* what I was looking for. Thanks.
konzepz
+1  A: 

I use HTML Tidy and YUI Compressor.

Martin