Building and compressing js libraries

We’re working on an internal build system here at CNET that is a mixture of things like Mootools download builder and Dean Edward’s /packer/ so that we can quickly include just the javascript that’s needed on a page.

Today’s post at Ajaxian shows that we’re not the only ones working on such a thing. Our solution though will likely be very specific to our application development, so I don’t know if we’ll be able to release it. In the comments of the post below, I also found a link to packtag, which seems to be an open source Java version of this very same functionality.

Via ajaxian:

We love to play with the plumbing don’t we. jscsscomp is the latest compressor that uses Nicolas Martin PHP version of the Dean Edwards JavaScript Compressor.

With a swish of mod_rewrite:

RewriteEngine on

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

you can get your JavaScript like this:

<script src = "/jscsscomp/yahoo.js, dom.js, event.js, effects/dragdrop.js, slider.js"></script>

Leave a Reply

You must be logged in to post a comment.