
Originally Posted by
epidemic
okay.. so basically it would be better to create one file? I'm estimating my stylesheet to be +- 50 KB when my site is finished.
It could make sense to break them up if you're only going to serve some on certain sections or pages of the site. If you're going to server them all on all pages then it really only makes sense to put them in one file to reduce hits to the server.
You can serve compressed output but there is a bit of a tradeoff in that the client machine(your site's visitor's machine) will have to decompress, which probably isn't a big deal.
Code:
<IfModule mod_rewrite.c>
RewriteEngine on
#### COMPRESS JS ####
RewriteCond %{HTTP:Accept-encoding} gzip
RewriteCond %{HTTP_USER_AGENT} !Safari
RewriteCond %{REQUEST_FILENAME}.gz -f
RewriteRule ^(.*).js$ $1.js.gz [QSA,L]
#### COMPRESS CSS ####
RewriteCond %{HTTP:Accept-encoding} gzip
RewriteCond %{HTTP_USER_AGENT} !Safari
RewriteCond %{REQUEST_FILENAME}.gz -f
RewriteRule ^(.*).css$ $1.css.gz [QSA,L]
</IfModule>
You need a compressed version of the file on your server in the same directory as the original file.
You can gzip it with:
gzip -c original_file_name.css > original_file_name.css.gz
Bookmarks