Fast Load JavaScript and CSS Files

Want to decrease response time of your webpages? Decreasing the size of JavaScript and CSS files is one of the techniques used for better performance of websites.

Yahoo Compression tool for JavaScript and CSS is excellent tool for minifying JavaScript and CSS files. It can achieve over 20% compression. I got 325 and 22% compression for my two JavaScript files.

YUI compressor is a small Java Application, which can reduce your JavaScript or CSS files in just a single command.

For minifying CSS:

$ java -jar build/yuicompressor-2.4.2.jar -o style_min.css style.css

where style.css is the original file with path.

For minifying JavaScript:

$ java -jar build/yuicompressor-2.4.2.jar -o javascript1_min.js --preserve-semi javascript1.js

javascript1.js is the original JavaScript file and javascript1_min.js will be minified version. Option --preserve-semi will preserve semicolon from original file.

YUI Javascript and CSS compression tool

Minifying or compressing JavaScript and CSS file is also useful when you try to reduce the bandwidth usage.