I'm looking for a website/program that will let me select multiple javascript files and output their minified versions in the order that they were selected. (E.g code of first selected files on top, last files in the end). Any ideas?
Closure compiler (and I suspect most of the big JS compressors) already allow for this.
From java -jar closurecompiler.jar --help
--js VAL
: The javascript filename. You may specify multiple
Update:
I created a little PHP script to do this check it out :D https://github.com/mario-deluna/packtacular
Ed Eliot (www.ejeliot.com) createt a pretty nice php script to pack multiple JavaScript files. I combined his script with the Jsmin class from Douglas Crockford to minify them.
Just Replace
foreach ($aFiles as $sFile) {
$aLastModifieds[] = filemtime("$sDocRoot/$sFile");
$sCode .= file_get_contents("$sDocRoot/$sFile");
}
with
foreach ($aFiles as $sFile) {
$aLastModifieds[] = filemtime("$sDocRoot/$sFile");
$sCode .= JSMin::minify(file_get_contents("$sDocRoot/$sFile"));
}
The YUI compressor supports that, too (for both JS an CSS files, by the way)
You could concatenate the files into a single file (cat [files] >
or type [files] >
) before minifying
精彩评论