Reliable and convenient JavaScript minifier [closed]

删除回忆录丶 提交于 2019-12-10 17:28:44

问题


I occasionally write JavaScript code. I am interested in minifying it for better performance, but I don't plan to spend to much time on that, especially in testing the minified result.

I found this online service: http://www.lotterypost.com/js-compress.aspx

So a couple questions:

  • Is it reliable?
  • Microsoft AJAX minifier vs. YUI Compressor, what's the best option?
  • Any other similar online tool to recommend (and why is it better than the above link)?

回答1:


That link you post happens to be the one that I use too.

Use the MS AJAX Minifer. It's way better than the yui one. besides:

http://stephenwalther.com/blog/archive/2009/10/16/using-the-new-microsoft-ajax-minifier.aspx:

The Microsoft Ajax team (I work on this team) has been using this tool internally for a number of years. For example, we use the Microsoft Ajax Minifier to minify the Microsoft Ajax Library before publishing it.

Well if you don't trust me, run your source code (if you don't have an actual source code to test, just grab the source at http://code.jquery.com/jquery-1.6.2.js) through both and see which is more "minified".

==

Google has the Google Closure Compiler but it analyzes your code and removes unreferenced code (to furthur reduce the size of the resultant file). However usually this is not what you want because even though the functions/variables are not referenced within that file, it may be referenced from your other js files that make up your site)




回答2:


Google's Closure Compiler is an excellent Javascript minifier and compiler. It analyzes the code and reports the detectable errors. It removes redundant space and unreferenced code, and renames objects to shortest possible names. You just need to compile together all Javascript files that belong to one HTML page.



来源:https://stackoverflow.com/questions/5840845/reliable-and-convenient-javascript-minifier

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!