缩小 Javascript 代码和 css 代码的最佳应用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10151998/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Best App to Minify Javascript code and css code
提问by fiberOptics
What is the best, safe and 100% free tool to be used on doing these task? It has been asked for many times but I want to ask those experienced user.
用于执行这些任务的最佳、安全且 100% 免费的工具是什么?已经问过很多次了,但我想问那些有经验的用户。
采纳答案by A Person
I use Google Closure Tools, it uses Rhino to intepret your code while modifying it to enusre that it still works after minification. Many free tools exists: YUI Compressor, UglifyJS, etc.
我使用 Google Closure Tools,它使用 Rhino 来解释您的代码,同时修改它以确保它在缩小后仍然有效。存在许多免费工具:YUI Compressor、UglifyJS 等。
UglifyJS is also good as well, try it here http://marijnhaverbeke.nl/uglifyjs
UglifyJS 也不错,在这里试试http://marijnhaverbeke.nl/uglifyjs
Google Closure Tools: https://developers.google.com/closure/
回答by cezar
Try MinifyCSS, it works also for JavaScript -> http://www.minifycss.com/
试试 MinifyCSS,它也适用于 JavaScript -> http://www.minifycss.com/
There are also JSMIN (http://www.crockford.com/javascript/jsmin.html) however it works only for JavaScript.
还有 JSMIN (http://www.crockford.com/javascript/jsmin.html) 但它只适用于 JavaScript。
回答by matpol
if you google minify there are many online minifiers for js - these basically all do the same thing. In terms of CSS there are similar things that will make the files files smaller. You need to be careful doing this with CSS though as you need to measure maintainability against file size - unless of course you auto minify when releasing to live. You still need to be careful as changing the css could have adverse effects to your site.
如果您使用 google minify,则有许多用于 js 的在线 minifiers - 这些基本上都做同样的事情。在 CSS 方面,有类似的东西可以使文件文件更小。您需要小心使用 CSS 执行此操作,因为您需要根据文件大小来衡量可维护性 - 当然除非您在发布时自动缩小。您仍然需要小心,因为更改 css 可能会对您的网站产生不利影响。