I tested 17 free tools to minify JavaScript online: after minifying with the best tool there are ca 43% of code remained, the "worst" tool (not really worst) remained ca 51% of code. It worth also to minify. To minify CSS gives ca 60% of less code - It worth also to minify too. Read further - i list all tested online minifying tools with stats and a few server-side traffic-saving hints :
I tested Javascript minifying with this 408 signs long script, which inserted into the < head > helps you to clean up your HTML-output:
function sanitize_output($buffer) { $search = array( '/\>[^\S ]+/s', // strip whitespaces after tags, except space '/[^\S ]+\</s', // strip whitespaces before tags, except space '/(\s)+/s' // shorten multiple whitespace sequences ); $replace = array( '>', '<', '\\1' ); $buffer = preg_replace($search, $replace, $buffer); return $buffer; } ob_start("sanitize_output");
Test results of javascript minifying
- 43,87% left, WINNER! http://javascript-minifier.com/
- 43,87% left, WINNER! http://marijnhaverbeke.nl/uglifyjs
- 43,87% left, WINNER! http://www.lotterypost.com/js-compress.aspx, used Microsoft Ajax Minifier
- 44,11% left, http://sundgaard.dk/javascript-minify.aspx
- 44,36% left, http://compressorrater.thruhere.net/
- 44,36% left, http://minify.avivo.si
- 44,36% left, http://javascriptcompressor.com/ shrink variables
- 44,36% left, http://www.freeformatter.com/javascript-minifier.html
- 44,36% left, http://htmlcompressor.com/compressor/
- 44,36% left, http://jscompress.com/
- 44,36% left, http://www.lotterypost.com/js-compress.aspx, used YUI Compressor
- 44,6% left, http://www.jscompressor.com/
- 45,83% left, http://shrinksafe.dojotoolkit.org/
- 50,24% left, http://www.jsmini.com/
- 51,47% signs left, http://javascriptcompressor.com/
- 51,71% left, left, http://htmlcompressor.com/compressor/, used Simple optimization
- 51,71% left, http://fmarcia.info/jsmin aggresive level
- 51,71% left, http://prettydiff.com/?m=minify
Test results of CSS-minifying tools
- 41,60% left, http://cssminifier.com/
- 41,60% left, http://www.lotterypost.com/css-compress.aspx
- 41,60% left, http://www.freeformatter.com/css-minifier.html
- 41,60% left, http://devilo.us/
- 41,60% left, http://toolswebtop.com/css/minify
- 43,64% left, http://www.cssdrive.com/compressor/compress.php
- 43,64% left, http://sundgaard.dk/css-minify.aspx
Server-side minifying
- Firstly look into your phpinfo.php (if you haven't one, simply create a text file, name it phpinfo.php and write inside
phpinfo()
and upload the file into your root directory) file and check, whether mod_gzip is available and on. - If mod_gzip is here and on, open your .htaccess file (if not existing, create one and upload after editing into your root directory) and add code from this file. Then save and upload.