0

I want to compress my css and js files at once.Because everyday I have to modify files and deploy them.Is there any tool that will compress these files at once ?

Thanks in Advance.

1
  • 1
    There are many. Are you looking for an online tool, or are you on Windows, Linux or Mac machine? Have you really Googled for a solution? Commented Nov 8, 2012 at 13:19

2 Answers 2

3

You can use YUI compressor, great tool if you have some understanding about java and command line.

The YUI Compressor is written in Java (requires Java >= 1.4) and relies on Rhino to tokenize the source JavaScript file. It starts by analyzing the source JavaScript file to understand how it is structured. It then prints out the token stream, omitting as many white space characters as possible, and replacing all local symbols by a 1 (or 2, or 3) letter symbol wherever such a substitution is appropriate (in the face of evil features such as eval or with, the YUI Compressor takes a defensive approach by not obfuscating any of the scopes containing the evil statement) The CSS compression algorithm uses a set of finely tuned regular expressions to compress the source CSS file. The YUI Compressor is open-source, so don't hesitate to look at the code to understand exactly how it works.

http://developer.yahoo.com/yui/compressor/

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

3 Comments

I wasn't aware that the YUI compressor did CSS. +1
Yes this is a very good tool, I have seen this working in one very big portal application where hundreds of css and js files were compressed in one shot as part of a build process after which the code was moved to production environment. Thanks for the up vote !!
@Susant Don't forget to mark the question as answered by clicking on the big arrow next to the best question.
0

You probably will need two tools: one for CSS and one for Javascript. A simple shell script can chain the two into an apparently single command.

Compass is a great CSS Minify tool (Among other things)

http://compass-style.org/

Javascript has a few options:

http://www.crockford.com/javascript/jsmin.html

http://developer.yahoo.com/yui/compressor/

I use a simple shell script that strings a few of these tools together, and then uploads them to the web in a single command. This is all a command-line solution for Unix/Linux/Mac variants, if you need a GUI or a Windows solution I wont be of much help.

Cheers!

EDIT:

Upon further review, YUI compressor is likely a good bet for an all-in-one solution. See Anmol Saraf's answer.

1 Comment

Thanks Tal for the suggestion. I am starting to work with YUI tool.\

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.