![]() Which is your favorite minification tool? Add it in the comment section below. It shows the aggregated statistics on the general level of compression in four of the tools covered above (namely JSMin, Dojo ShrinkSafe, YUI Compressor, and Packer). To compare the different tools with your JavaScript code without setting up all the tools yourself, you can try the JavaScript CompressorRater. Bonus Tool (To Discover the Best Minification Tool for You) Finding the right tool to compress your JavaScript code can be a bit tough, as in many cases, it depends on your application. This means that you can drop the compressed version of your JavaScript into your pages without changing the code that uses it. Best of all, ShrinkSafe will never change a public variable or API. It can typically reduce the size of your scripts by a third or more, depending on your programming style. ShrinkSafe is another compressor that parses the JavaScript using the rhino library and crunches local variable names. It can go beyond regular compression and add advanced on-the-fly decompression with a JavaScript runtime piece. Just paste in the code and hit the ‘Pack’ button. Alternatively, you can use the grunt-contrib-uglify plugin. This will run the uglify task, which will minify your Javascript files and save the resulting code to the output file specified in the Gruntfile.js file. Run Grunt using the following command: grunt. ![]() Packer by Dean Edwards is also a very popular JavaScript compressor, which automatically creates a compressed version of your code. Replace the file paths in the code above with the paths to your input and output files. It also encourages a more expressive programming style because it eliminates clean, literate self-documentation downloads. It typically reduces file size by half, resulting in faster downloads. JSMin removes comments and unnecessary whitespace from JavaScript files. It also checks syntax, variable references, and types and warns about common JavaScript pitfalls. It parses your JavaScript, analyzes it, removes dead code, and rewrites and minimizes what’s left. ![]() Instead of compiling from a source language to machine code, it compiles from JavaScript to better JavaScript. Google Closure Compiler is a tool for making JavaScript download and run faster. ![]() It is 100% safe and yields a higher compression ratio than most other tools. The YUI Compressor is also able to compress CSS files. Bonus Tool (To Discover the Best Minification Tool for You)ĭeveloped by Yahoo!, YUI Compressor is a command-line tool written in Java that allows you to minify your JavaScript files. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |