0

I have many js files, with some naming convention. If there any tool that concatenate all this files in one, so I don't need to include them all separately ?

1
  • 1
    What exactly do you mean with automatically? On build? Pre deployment? On page request? Commented Mar 10, 2010 at 16:24

5 Answers 5

1

You could look at using a JS Minifier, like:

  1. http://code.google.com/p/minify/
  2. http://code.google.com/closure/compiler/
  3. http://www.crockford.com/javascript/jsmin.html
Sign up to request clarification or add additional context in comments.

Comments

1

Something like:

$> cat file1.js file2.js ... > allfiles.js

?

Comments

0

In bash:

for file in `ls *js` ; do cat "$file" >> outputscript.js; echo >> "$file"; done;

1 Comment

echo >> outputscript.js possibly, don't see the point of adding a newline to the old files
0

You might find some helpful information here. Several answers advocate creating multiple javascript files during development, just so developers don't go crazy scrolling through thousands of lines of code. Those files are then merged during deployment -- several approaches are suggested. Several respondents also advocate using minification, which can reduce the size of the resulting mega-file.

Comments

0

In addition to the straightforward answers like using cat or a minifier, you can also use Sprockets, which is a JavaScript build system written in Ruby. Prototype JS uses Sprockets (in fact it Sprockets was written for Prototype).

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.