Minify Jquery Based Js Files

Minify jQuery based js files

The YUI Compressor is a tool I use, it compresses both JS and CSS well, and it is written in Java (so you can work it into a build process via ant).

Someone's even made an online version of it.

How to minify jquery files?

If you're familiar with Java you could also use YUI compressor to minify JS (and CSS) files yourself. We use it here as well and it works great.

Algorithm used to minify js file based on Jquery?

  1. To Minify JS:

http://dean.edwards.name/packer/

http://crockford.com/javascript/jsmin

http://code.google.com/intl/pl/closure/compiler/

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

http://ajaxmin.codeplex.com/

  1. You can write algo for minify your js by yourself but it would be better to use any of the above tools for this. Reason is that they are already providing good minification and they are time-tested

  2. Minifying is a reversible process. Since browsers can only understand javascript, these algos need to be reversible. and so others can also reverse the minification.

How to minify java script files in a rails application?

In production.rb

config.assets.compile = true

RAILS_ENV=production rake assets:precompile

and push all compressed js/css files. It will save your load time and compress all js/css/images.

What's the difference between jquery.js and jquery.min.js?

They are both the same functionally but the .min one has all unnecessary characters removed in order to make the file size smaller.

Just to point out as well, you are better using the minified version (.min) for your live environment as Google are now checking on page loading times. Having all your JS file minified means they will load faster and will score you more brownie points.

You can get an addon for Mozilla called Page Speed that will look through your site and show you all the .JS files and provide minified versions (amongst other things).

Minify/Combining JS Files

There is the Closure Compiler from Google, that will combine JS files and minify them to a level of your choosing. It certainly saves a great deal of playing about with cutting & pasting which, as you probably know, can get very complicated.



Related Topics



Leave a reply



Submit