We don’t allow questions seeking recommendations for software libraries, tutorials, tools, books, or other off-site resources. You can edit the question so it can be answered with facts and citations.
Closed 10 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(3)
这些是 javascript minifer
http://www.crockford.com/javascript/jsmin.html
http://dean.edwards.name/weblog/2007/04/packer3/
这是在线 javascript 代码压缩器
http://javascriptcompressor.com/
These are javascript minifers
http://www.crockford.com/javascript/jsmin.html
http://dean.edwards.name/weblog/2007/04/packer3/
This is online javascript code compressor
http://javascriptcompressor.com/
我用的是雅虎!压缩器,我使用.net版本,但看起来好像有一个 php 模块< /a> 有人发布了。我个人没有使用过它,所以不能保证它。
I use the Yahoo! compressor, I use the .net version but it looks as though there is a php module that someone has published. I haven't used it personally so can't vouch for it.
我使用 UglifyJS 它不仅是用 JavaScript 编写的,而且还使用 NodeJS(一种后端 JavaScript 编程语言)来压缩 JavaScript 文件。对我来说,这是使用 Google Closure 或 Uglify 和 研究表明 Uglify/Node 速度更快,并且文件稍小。像 jQuery 这样的库也已转移到 Uglify。
设置 UglifyJS 并不难。您无需了解 Node 即可使用它(尽管如果您了解 JavaScript,您就已经非常了解 Node)了。 UglifyJS 既是一个 shell 实用程序,又是一个 Node js 库,您可以在 Node 脚本中导入和使用。我继续进行后面的操作,因为深入了解 Node 很有趣,但您也可以编写一个 php 脚本来下拉到 shell 并使用 Node shell 实用程序。不过,在任何一种情况下,您都需要为您的服务器编译 Node(这也会安装 V8 JavaScript 引擎)。
安装 Node 后,您可以执行其他有趣的操作,例如设置 jshint 来验证服务器上的 JS。
I use UglifyJS which is not only written in JavaScript but uses NodeJS (a backend JavaScript programming language) to compress your JavaScript files. For me it was a tossup between using Google Closure or Uglify and research showed that Uglify/Node was faster and led to slightly small files. Libraries like jQuery have also moved to Uglify.
Setting up UglifyJS is not that hard. You don't need to know Node to use it (though if you know JavaScript you pretty much know Node already). UglifyJS comes as both a shell utility and a Node js library you can import and use in your Node script. I went ahead and did the later as diving into Node was fun, but you could also write a php script to drop down to shell and use the Node shell utility. You do need to compile Node for your server in either situation, though (which also installs the V8 JavaScript engine).
Once you have Node installs you could do additional fun things like setup jshint to validate your JS on your server.