开发者

Easiest way to pack/minify multiple javascript files? [duplicate]

This question already has answers here: Closed 11 years ago. 开发者_运维知识库

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜