0

So, I'm working on a big project where there is a need for a tone of JS, so I don't want to write everything in one file, just because it gets confusing working on it, and with the time will be even harder to keep track with everything.

So my plan is to split in multiple files and folders like.

js/home/register.js
js/home/login.js

But I want everything compiled in one files, I will like to use something like SASS has @import for styles, or something to take the files and compile automatically in one.

What's the best tool out here that you recommend guys?

4
  • possible duplicate of Combine multiple jquery script files into one js file Commented Nov 12, 2012 at 22:50
  • 2
    "Best" questions are generally off-topic for SO, see the FAQ for details. Commented Nov 12, 2012 at 22:50
  • 1
    @T.J.Crowder. Actually they are "Not Constructive" :) Commented Nov 12, 2012 at 22:51
  • @gdoron: Quite, that would be the technical close-reason term. ;-) Commented Nov 12, 2012 at 22:52

2 Answers 2

3

You can use any of several tools for this, including cat (on *nix systems) or copy (on Windows systems).

It probably makes sense to use a compiling / compressing / minifying / packing tool like the Closure Compiler, YUI Compressor, jsmin, or packer3. But which one you use is really up to you, the needs of your project, etc.

Sign up to request clarification or add additional context in comments.

1 Comment

You might want to add an answer to this question
0

Please see this SO question.

On linux you can use simple shell script https://github.com/dfsq/compressJS.sh to combine multiple javascript files into the single one. It makes use of the Closure Compiler online service so the resulting script is also effectively compressed.

The solution is to use whatever tool you like to combine the JS files before you upload them to your webserver. Dev environment != production environment. The only possible problem is that you create functions/variables with the same name, but then again I think there are tools to cope with that while joining them together.

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.