We are using jQuery in our project. We have numerous custom javascript files in our web-app that have UDFs utilizing the jQuery features. We need to reduce the size (as a part of performance improvement activities) and I am looking for a reliable 'minifier' for these files (it would be great if the same tool could minify the CSS files too)
We tried JSLint and JSMin - but JSLint does not complete and throws many exceptions as soon as it encounters jQuery code.
To minify JavaScript, try UglifyJS. The Closure Compiler is also very effective. You can create a build process that uses these tools to minify and rename the development files and save them to a production directory.
Minifying strips out all comments, superfluous white space and shortens variable names. It thus reduces download time for your JavaScript files as they are (usually) a lot smaller in filesize. So, yes it does improve performance. The obfuscation shouldn't adversely affect performance.
js . Simply copy + paste the code starting with cat, including the EOT on the last line, and press . Use the command minify followed by the path to and name of the js file intended to be minified. This will minify the code and output it to the screen.
It is important to minify your CSS and minimise JavaScript files so they can load faster on your web pages. There are many reasons why you should minify your CSS and JavaScript: Reduce file size: The more code there is in a file, the larger it will be. Minified code is usually much smaller than the original version.
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.
There's also a .NET port of YUI Compressor which allows you to:-
because this is a port of the (original) java version YUI Compressor, which a few peeps mention above, it should give you the same results BUT all in the .NET environment -- no need for java.
HTH.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With