Reputation:
What is the best way to compress or minify jQuery, javascript and CSS files?
I am new with the compressions and minify features of web development please help me.
Upvotes: 10
Views: 2690
Reputation: 3337
You can use require.js optimizer within node.js or Java, which supports both optimize the code itself and also minimize it [ If you are using require.js ] You can use Google Web Toolkit restful api to increase performance of your codes and also for minifying purposes You can use ASP.NET bundling for minifying You can use Grunt to automate you unit tests and minifying
Upvotes: 0
Reputation: 6963
You can try http://www.jasob.com/ it allow you to Obfuscation and compression for JS and CSS
Upvotes: 0
Reputation: 1871
I recommend using a tool which is provided or can integrate with your framework/toolset, to handle this automatically.
If you are using django, I recommend spaceless
template tag or django-htmlmin
app for html templates and django_compressor
for js/css.
Upvotes: 0
Reputation: 7463
I personally use Yahoo Compressor and would recommend it. Why? Because it works.
An example of how to execute it at the command line:
java -jar yuicompressor-2.4.7.jar javascriptfile.js -o outputfile.js --charset utf-8
Do the same on a CSS file:
java -jar yuicompressor-2.4.7.jar style.css -o outputstyle.css --charset utf-8
Actually, I just realized I use a thing called htmlcompressor for HTML files:
java -jar htmlcompressor-1.5.3.jar hmlfile.html --remove-intertag-spaces --compress-js
Google's Closure Compiler looks good as well, but I have not personally used it yet so I'm not sure if it does CSS and HTML as well as Javascript.
Upvotes: 4