1

I'm using Yahoo's Minifier here:

http://refresh-sf.com/yui/

I use it to compress CSS and Javascript. It also has the option to zip/encode the data.

The .css version looks like this - ArcC.min.css.gz

The .js version looks like this - ArcJ.min.js.gz

Can I plug this in to my HTML directly like this, after I upload the files to my server?

<link rel="stylesheet" type="text/css" href="ArcC.min.css.gz"/>

<script type="text/javascript" src="ArcJ.min.js.gz"></script>
  • Just tested...that breaks my page....O.K...so I how do I use these zipped files then? –  Mar 26 '12 at 19:54
  • You don't directly serve up gzipped files for use like that. You put in normal uncompressed files, and configure the webserver to gzip them on the fly. – Marc B Mar 26 '12 at 19:56

2 Answers2

1

Some browsers don't support gzipped files. It's best to let the server do the compression. Your server should be able to decide whether to send a gzipped version or an uncompressed version, based on the Accept-Encoding header the browser submitted with the request.

How to set up your server for gzip:

IIS: Answer on Stackoverflow
Apache: mod_deflate documentation

Community
  • 1
  • 1
gilly3
  • 87,962
  • 25
  • 144
  • 176
1

See this article on gziping CSS. As mentioned in the article, the best solution is to have your server gzip all outgoing files.

Here's the relevant code from that page.

<?php 
ob_start ("ob_gzhandler");
header("Content-type: text/css; charset: UTF-8");
header("Cache-Control: must-revalidate");
$offset = 60 * 60 ;
$ExpStr = "Expires: " . 
gmdate("D, d M Y H:i:s",
time() + $offset) . " GMT";
header($ExpStr);
?>

.htaccess:

AddHandler application/x-httpd-php .css
php_value auto_prepend_file gzip-css.php
php_flag zlib.output_compression On
Brigand
  • 84,529
  • 20
  • 165
  • 173