diTii.com Digital News Hub

Sign up with your email address to be the first to know about latest news and more.

I agree to have my personal information transfered to MailChimp (more information)

Apr262007

jscsscomp: JavaScript and CSS files compressor

jscsscomp is a PHP script what compress JavaScript and CSS files when they are requested from the server. It uses Nicolas Martin PHP version of the Dean Edwards JavaScript Compressor, also uses ideas and code from Patrick Hunlock.

Download

Install note: You need PHP5 (because of class.JavaScriptPacker.php)

1. get archive with jscsscomp
2. extract archive somethere on your disc
3. copy jscsscomp folder to the document root of your site
4. jscsscomp/cache/ dir should be writable for your scripts (or caching will not work)
5. add this code to the .htaccess file in doc root


RewriteEngine on

RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^(.*\.)(js|css)$ jscsscomp/jscsscomp.php?q=$1$2 [L,NC] 

or simply copy one from the distribution

From this point all your JS and CSS files should be served compressed by gzip (if browser accepts gzip compression) or by packer (only for JS files)

One file trick:

(this part is copied from here), If you use a lot of JS (or CSS) files







you can get all this files (compressed!) in one request:

Note: i guess you understand what mixing .css and .js files in one request is not a good idea… (;

Doing without ModRewrite: If mod-rewrite is not installed, or you can’t use it, write URLs in this way:


jscsscomp

jscsscomp, java, script, javascript, css, files compressor, optimization, faster loading

Share This Story, Choose Your Platform!

Do NOT follow this link or you will be banned from the site!