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?
- 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/
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
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
How to Detect Internet Explorer (Ie) and Microsoft Edge Using JavaScript
How to Display Selected Image Without Sending Data to Server
Remove Specific HTML Tag with Its Content from JavaScript String
Serving High Res Images to Retina Display
Make the on Scroll Growing <Path> to Dashed Line
How to Style Canvas Elements with CSS
How to Get All Valid Keywords for CSS Property
Bootstrap 3 Compatible with Current Angularjs Bootstrap Directives
How to Disable Ie10 History Swipe Gesture
How to Open Bootstrap Modal in Ajax Success
Can You Do a JavaScript for Loop Inside of Less CSS
Remove Url and Print Text from the Printed Page
Detect and Log When External JavaScript or CSS Resources Fail to Load
How to Remove an Important CSS Property
JavaScript Hide/Show Div on Checkbox: Checked/Unchecked