April 26, 2007
4:13 pm

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

[code]
RewriteEngine on

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

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

[java]





[/java]

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

[java][/java]

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:

[java]

[/java]

jscsscomp

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

Related Posts:

No followup yet

Leave a Response

Comment Preview
« Hand gestures on the horizon for Microsoft Virtual EarthFaster Page Loads With Image Concatenation »
Feed Icon

Subscribe via RSS or email: