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?
Asked
Active
Viewed 5,633 times
5
-
1Not a duplicate as I'm asking specifically for something that supports compressing multiple files – Ali Jun 28 '11 at 15:46
-
1I agree with you actually. I don't think it's a dupe. Well, ... not of *that* question anyway. – tjm Jun 28 '11 at 15:49
4 Answers
5
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

tjm
- 7,500
- 2
- 32
- 53
-
With how long it would take to type up all of that + all the names of the files, i might as well just manually compress each file through a web compresser. – Ali Jun 28 '11 at 14:24
-
@Click True. But you could write a simple script that passes files off to closurecompiler to reduce the typing that you'd need. – tjm Jun 28 '11 at 14:26
-
2I use the online version of Closure compiler, that way i dont have to mess with CMD. http://closure-compiler.appspot.com/home – Webbies Jun 28 '11 at 14:33
2
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"));
}

Mario
- 3,339
- 2
- 22
- 41
1
The YUI compressor supports that, too (for both JS an CSS files, by the way)

Alex Gyoshev
- 11,929
- 4
- 44
- 74
0
You could concatenate the files into a single file (cat [files] >
or type [files] >
) before minifying

Karoly Horvath
- 94,607
- 11
- 117
- 176