Take the 2-minute tour ×

I have a web application with lots of Javascipt and CSS code. I want to minify the CSS and JS code using something like UglifyJS.

However, I don't want to program with the minified code and I want my team to checkout only the non-minified code. What's the most common way of doing this?

I guess you would push both the minified and non-minified code and have the code reference only minified files. Do most people create a file call BUILD that runs all JS/CSS files through the minifier? Programmers would then have to run the BUILD script before pushing right?

share|improve this question

2 Answers 2

up vote 6 down vote accepted

Yes, the build script is usually used to minify CSS and JavaScript code into two files.

You run it:

  • before tests (unless you're 100% sure that a solution which works with original code will also work with minified code. With CSS, it's easy. With JavaScript, if you use for example Closure Compiler with Advanced optimization, be ready to be surprised).

  • when deploying the application.

You don't run it:

  • when committing source code changes to version control (in all cases, there are no reasons to have minified files under version control).

  • each time you, as a developer, make a small change to the code in development environment. Otherwise, it would be too cumbersome.

share|improve this answer

More or less. It is probably more common to use (instead of a custom BUILD shell script) make or Ant and let Jenkins deal with running the builds and deploying to an integration server.

share|improve this answer

Your Answer


