你用什么来最小化和压缩JavaScript库?

时间:2022-04-25 07:16:18

What do you use to minimize and compress JavaScript libraries?

你用什么来最小化和压缩JavaScript库?

17 个解决方案

#1


33  

I use YUI Compressor. Seems to get the job done well!

我使用YUI Compressor。似乎很好地完成了工作!

#2


42  

I've used YUI Compressor for a long time and have had no problems with it, but have recently started using Google Closure Compiler and had some success with it. My impressions of it so far:

我已经使用了YUI Compressor很长一段时间并没有遇到任何问题,但最近开始使用Google Closure Compiler并取得了一些成功。到目前为止我对它的印象:

  • It generally outperforms YUI Compressor in terms of file size reduction. By a small amount on simple mode, and by a lot on advanced mode.
  • 它在文件大小减少方面通常优于YUI Compressor。在简单模式上少量,在高级模式上有很多。
  • Simple mode has so far been as reliable as YUI Compressor. Nothing I've fed it has shown any problems.
  • 到目前为止,简单模式与YUI Compressor一样可靠。我没有喂过任何东西已经显示出任何问题。
  • Advanced "compilation" mode is great for some scripts, but the dramatic size reduction of your script comes at the expense of a lot of meddling with your code that stands a decent chance of breaking it. There are ways to deal with some of these problems and understanding what it's doing can go a long way to avoiding problems but I generally avoid using this mode.
  • 高级“编译”模式对于某些脚本来说非常有用,但是脚本的大幅减少是以牺牲大量干扰代码为代价的,而这些代码有可能破坏它。有一些方法可以解决其中的一些问题,并了解它正在做什么可以大大有助于避免问题,但我通常避免使用这种模式。

I've moved over to using Google Closure Compiler in simple "compilation" mode, because it slightly outperforms YUI Compressor in general. I have used it considerably less than I have YUI Compressor but from what I've seen so far I'd recommend it.

我已经转而使用Google Closure Compiler进行简单的“编译”模式,因为它总体上略胜于YUI Compressor。我使用它比使用YUI Compressor要少得多,但从我到目前为止看到的我推荐它。

One other that I've yet to try but sounds promising is Mihai Bazon's UglifyJS.

另一个我尚未尝试但听起来很有希望的是Mihai Bazon的UglifyJS。

#3


22  

You have a herd of possibilities here:

你有一堆可能性:

  • The YUI Compressor mentioned by other answers,
  • YUI Compressor通过其他答案提到,
  • The Google Closure Compiler,
  • Google Closure编译器,
  • The Dojo ToolKit's ShrinkSafe compiler used by their build system,
  • Dojo ToolKit的构建系统使用的ShrinkSafe编译器,
  • Douglas Crockford's still actual JSMin,
  • 道格拉斯·克罗克福德仍然是真正的JSMin,
  • UglifyJS mentioned by others,
  • UglifyJS被其他人提及,
  • And a commercial solution, javaScript Obfuscator (never used personally)
  • 和商业解决方案,javaScript Obfuscator(从未个人使用)

From my personal experience, I'd recommend that you use the Dojo SDK to build a custom build, which you can then in turn configure to either use their usual ShrinkSafe compiler, or Google Closure, which they now support as well.

根据我的个人经验,我建议您使用Dojo SDK构建自定义构建,然后您可以配置为使用他们通常的ShrinkSafe编译器,或者他们现在支持的Google Closure。

In terms of compression, I think Google Closure is the one yielding the best results for me so far, however I am usually satisfied with ShrinkSafe and it's a bit older and more robust, whereas Closure Compiler looks a bit of a new kid on the block (which your stakeholders might not be too fond of, for instance).

在压缩方面,我认为Google Closure是迄今为止对我产生最好结果的那个,但是我对ShrinkSafe感到满意,它有点老了,更强大,而Closure Compiler在块上看起来有点像新手(例如,您的利益相关者可能不太喜欢)。

Some people swear only by the YUI Compressor though. I personally cannot really vouch for it.

有些人发誓只有YUI Compressor。我个人不能保证它。

Now if you question was to compress libraries and not just your own JavaScript code, it obviously gets really more involved, as you will need for most of these tools to export the symbols that should not be renamed or stripped. Most decent compressors will remove functions that they think are unused - often the case in a library, if not bound to a project, obviously - and change the names to make them shorter and use less characters - also a problem as you obviously want a public API to not be tampered with.

现在,如果您提出的问题是压缩库而不仅仅是您自己的JavaScript代码,那么它显然会更加复杂,因为您需要大多数这些工具来导出不应重命名或剥离的符号。最理想的压缩器将删除他们认为未使用的函数 - 通常是库中的情况,如果没有绑定到项目,显然 - 并更改名称以缩短它们并使用更少的字符 - 这也是一个问题,因为你显然想要公开API不会被篡改。

You can find other threads on this topic as well and find information in the tools' support documentation. You may also want to have a look at JSBuilder2, some sort of pendant to Dojo's Build tool (so, using ShrinkSafe or Closure Compiler) for ExtJS (using the YUI compressor).

您还可以在此主题中找到其他主题,并在工具的支持文档中查找信息。您可能还想看看JSBuilder2,它是Dojo的Build工具的一些吊坠(因此,使用ShrinkSafe或Closure Compiler)用于ExtJS(使用YUI压缩器)。

(Sorry, being a new SO user, I cannot add more than one link so I cannot link directly to the tools.)

(对不起,作为新的SO用户,我无法添加多个链接,因此无法直接链接到工具。)

EDIT: regarding the concerns expressed in some answers that compression might introduce bugs and that it makes debugging easier as the code is not mangled: yes, it's a valid concern. However:

编辑:关于在一些答案中表达的担忧,压缩可能会引入错误,并且由于代码没有被破坏,它使调试变得更容易:是的,这是一个有效的问题。然而:

  • you will get a very significant improvement in terms of bandwidth if you use a minifier, even with gzip compression activated (and you can learn to leverage gzip compression by making the compressor's life easier
  • 如果使用缩放器,即使激活了gzip压缩,你的带宽也会得到非常显着的改善(你可以通过让压缩器的生活变得更轻松来学习利用gzip压缩
  • you should just taste your code in debug and production mode to ensure the behavior is identical. I mean, it's part of your job as well...
  • 您应该在调试和生产模式下品尝您的代码,以确保行为完全相同。我的意思是,这也是你工作的一部分......
  • some of these compressors have been around for a while and won't really introduce bugs into your code. They're really just re-organizing things and substituting strings, really.
  • 其中一些压缩器已存在一段时间,并不会真正在您的代码中引入错误。他们真的只是重新组织事物并取代字符串。
  • some compressors (for instance the dojo build system) come with options to allow you to produce both a compressed and an uncompressed output, so that you can then enable different modes for debugging and production, using query parameters for instance.
  • 一些压缩器(例如dojo构建系统)提供了允许您生成压缩和未压缩输出的选项,以便您可以使用查询参数启用不同的调试和生成模式。

#4


12  

I don't minimize JavaScript at all: gzip compression is good enough for me and has the additional benefit that error messages will still be useful.

我根本没有最小化JavaScript:gzip压缩对我来说足够好,并且还有一个额外的好处,即错误消息仍然有用。

#5


11  

I too use YUI Compressor. I have an ant task like this that I use in my projects:

我也使用YUI Compressor。我在我的项目中使用了这样的ant任务:

<!--
YUI Compressor tasks 
http://www.julienlecomte.net/yuicompressor/README
-->
<property name="yuicompressor.jar"
           value="C:/devlibs/yuicompressor-2.2.4/build/yuicompressor-2.2.4.jar"/>

<target name="js.compress">
    <!-- Create min directory under js direcrtory if it doesnt exist -->
    <mkdir dir="${js-directory}/min" />

    <apply verbose="true" executable="java" parallel="false" failonerror="true">
        <fileset dir="${js-directory}" includes="*.js"/>
        <arg line="-jar"/>
        <arg path="${yuicompressor.jar}"/>
        <srcfile/>
        <arg line="-o"/>
        <mapper type="glob" from="*.js" to="${js-directory}/min/*-min.js"/>
        <targetfile/>
    </apply>
</target>

#6


5  

UglifyJS is a new one.

UglifyJS是一个新的。

UglifyJS compresses better than YUI Compressor and just about on par with the Google Closure Compiler. For example, the compressed version of jQuery from the Google Closure Compiler is only 403 bytes smaller than the version produced by UglifyJS - impressive! UglifyJS is also the fastest to run by a long shot, beating Closure by over 6 seconds!

UglifyJS比YUI Compressor压缩得更好,与Google Closure Compiler差不多。例如,来自Google Closure Compiler的jQuery的压缩版本仅比UglifyJS生成的版本小403字节 - 令人印象深刻! UglifyJS也是最快的一次击球,击败Closure超过6秒!

Additionally, the code produced by UglifyJS is safer than the code that Closure generates. For example, Closure doesn’t know how to deal with eval or with{} - it just logs an error and continues to rename variables anyway. This, obviously, leads to broken code. UglifyJS does not have this problem.

此外,UglifyJS生成的代码比Closure生成的代码更安全。例如,Closure不知道如何处理eval或使用{} - 它只记录错误并继续重命名变量。显然,这会导致代码损坏。 UglifyJS没有这个问题。

More information can be found here: http://badassjs.com/post/971960912/uglifyjs-a-fast-new-javascript-compressor-for-node-js

更多信息可以在这里找到:http://badassjs.com/post/971960912/uglifyjs-a-fast-new-javascript-compressor-for-node-js

#7


4  

Dean Edward's packer achieves some pretty good compression ratios. It has command line implementations which allows it to be used in a continuous integration process.

Dean Edward的打包机实现了一些非常好的压缩比。它具有命令行实现,允许它在持续集成过程中使用。

#8


4  

Google's closure tools

谷歌的关闭工具

You can map the minified version to the regular source code for debugging in Firebug with their add-on.

您可以将缩小版本映射到常规源代码,以便在Firebug中使用其附加组件进行调试。

#9


3  

I have tried YUI compressor before, but it gives me error message.

我之前尝试过YUI压缩器,但它给了我错误信息。

I suggest using JSMIN to minify your javascript:

我建议使用JSMIN来缩小你的javascript:

http://www.crockford.com/javascript/jsmin.html

http://www.crockford.com/javascript/jsmin.html

#10


3  

Here's a solution from Microsoft that you can integrate into Visual Studio to minify the files automatically when you build your project.

这是Microsoft的一个解决方案,您可以将其集成到Visual Studio中,以便在构建项目时自动缩小文件。

To Install:

安装:

Download the msi from : http://aspnet.codeplex.com/releases/view/40584

从http://aspnet.codeplex.com/releases/view/40584下载msi

You may need to restart your computer after its finished.

完成后,您可能需要重新启动计算机。

To Use:

使用方法:

Edit your .csproj file and include the following at the end of the file (but before the </Project> tag):

编辑.csproj文件并在文件末尾包含以下内容(但在 标记之前):

<Import Project="$(MSBuildExtensionsPath)\Microsoft\MicrosoftAjax\ajaxmin.tasks" />

<Target Name="AfterBuild">
    <ItemGroup>
        <JS Include="**\*.js" Exclude="**\*.min.js;Scripts\*.js" />
        <CSS Include="**\*.css" Exclude="**\*.min.css" />
    </ItemGroup>
    <AjaxMin 
    JsSourceFiles="@(JS)"
    JsSourceExtensionPattern="\.js$"
    JsTargetExtension=".min.js"
    CssSourceFiles="@(CSS)"
    CssSourceExtensionPattern="\.css$"
    CssTargetExtension=".min.css"/>
</Target>

Now when you build your project, all CSS and js files that don't end in .min.js, .min.css will be minified (See the "Exclude" attribute to exclude other files from being minified).

现在,当您构建项目时,所有未以.min.js,.min.css结尾的CSS和js文件将被缩小(请参阅“排除”属性以排除其他文件被缩小)。

#11


1  

http://code.google.com/p/jsmin-php/

http://code.google.com/p/jsmin-php/

Good old Doug Crockford :-) The beauty of this is that with cache control you can get somelovely automated compression only when it is required. Or in one of my projects I just output the compressed/gzipped files and delete them when I make a change. For a development environment, I just dont' call the minification script.

好老道格克罗克福德:-)这样做的好处在于,通过缓存控制,只有在需要时才能获得一些自动压缩。或者在我的一个项目中,我只输出压缩/ gzip文件,并在进行更改时删除它们。对于开发环境,我只是不称之为缩小脚本。

#12


0  

I use a simple (3-4 line) wrapper script around JavaScript::Minifier::XS.

我在JavaScript :: Minifier :: XS周围使用了一个简单的(3-4行)包装器脚本。

#13


0  

Here is an article which described how to use YUI Compressor for minimizing files during build: Compressing JS files as part of your build process

这篇文章描述了如何使用YUI Compressor在构建期间最小化文件:压缩JS文件作为构建过程的一部分

#14


0  

I use perl's JavaScript::Minifier. It works pretty well and you can e.g. replace some phrases using perl.

我使用perl的JavaScript :: Minifier。它工作得很好,你可以,例如用perl替换一些短语。

#15


0  

http://caja.appspot.com/tools/index does all three of HTML/CSS/JS.

http://caja.appspot.com/tools/index完成了所有三个HTML / CSS / JS。

#16


0  

https://jawr.dev.java.net/ is excellent for minification and versioning

https://jawr.dev.java.net/非常适合缩小和版本控制

#17


0  

There is a very good online compressor:

有一个非常好的在线压缩机:

http://javascriptcompressor.com/

http://javascriptcompressor.com/

You can also shrink variables, if you want even more compresed.

如果你想要更加复杂,你也可以缩小变量。

Hope it helps

希望能帮助到你

#1


33  

I use YUI Compressor. Seems to get the job done well!

我使用YUI Compressor。似乎很好地完成了工作!

#2


42  

I've used YUI Compressor for a long time and have had no problems with it, but have recently started using Google Closure Compiler and had some success with it. My impressions of it so far:

我已经使用了YUI Compressor很长一段时间并没有遇到任何问题,但最近开始使用Google Closure Compiler并取得了一些成功。到目前为止我对它的印象:

  • It generally outperforms YUI Compressor in terms of file size reduction. By a small amount on simple mode, and by a lot on advanced mode.
  • 它在文件大小减少方面通常优于YUI Compressor。在简单模式上少量,在高级模式上有很多。
  • Simple mode has so far been as reliable as YUI Compressor. Nothing I've fed it has shown any problems.
  • 到目前为止,简单模式与YUI Compressor一样可靠。我没有喂过任何东西已经显示出任何问题。
  • Advanced "compilation" mode is great for some scripts, but the dramatic size reduction of your script comes at the expense of a lot of meddling with your code that stands a decent chance of breaking it. There are ways to deal with some of these problems and understanding what it's doing can go a long way to avoiding problems but I generally avoid using this mode.
  • 高级“编译”模式对于某些脚本来说非常有用,但是脚本的大幅减少是以牺牲大量干扰代码为代价的,而这些代码有可能破坏它。有一些方法可以解决其中的一些问题,并了解它正在做什么可以大大有助于避免问题,但我通常避免使用这种模式。

I've moved over to using Google Closure Compiler in simple "compilation" mode, because it slightly outperforms YUI Compressor in general. I have used it considerably less than I have YUI Compressor but from what I've seen so far I'd recommend it.

我已经转而使用Google Closure Compiler进行简单的“编译”模式,因为它总体上略胜于YUI Compressor。我使用它比使用YUI Compressor要少得多,但从我到目前为止看到的我推荐它。

One other that I've yet to try but sounds promising is Mihai Bazon's UglifyJS.

另一个我尚未尝试但听起来很有希望的是Mihai Bazon的UglifyJS。

#3


22  

You have a herd of possibilities here:

你有一堆可能性:

  • The YUI Compressor mentioned by other answers,
  • YUI Compressor通过其他答案提到,
  • The Google Closure Compiler,
  • Google Closure编译器,
  • The Dojo ToolKit's ShrinkSafe compiler used by their build system,
  • Dojo ToolKit的构建系统使用的ShrinkSafe编译器,
  • Douglas Crockford's still actual JSMin,
  • 道格拉斯·克罗克福德仍然是真正的JSMin,
  • UglifyJS mentioned by others,
  • UglifyJS被其他人提及,
  • And a commercial solution, javaScript Obfuscator (never used personally)
  • 和商业解决方案,javaScript Obfuscator(从未个人使用)

From my personal experience, I'd recommend that you use the Dojo SDK to build a custom build, which you can then in turn configure to either use their usual ShrinkSafe compiler, or Google Closure, which they now support as well.

根据我的个人经验,我建议您使用Dojo SDK构建自定义构建,然后您可以配置为使用他们通常的ShrinkSafe编译器,或者他们现在支持的Google Closure。

In terms of compression, I think Google Closure is the one yielding the best results for me so far, however I am usually satisfied with ShrinkSafe and it's a bit older and more robust, whereas Closure Compiler looks a bit of a new kid on the block (which your stakeholders might not be too fond of, for instance).

在压缩方面,我认为Google Closure是迄今为止对我产生最好结果的那个,但是我对ShrinkSafe感到满意,它有点老了,更强大,而Closure Compiler在块上看起来有点像新手(例如,您的利益相关者可能不太喜欢)。

Some people swear only by the YUI Compressor though. I personally cannot really vouch for it.

有些人发誓只有YUI Compressor。我个人不能保证它。

Now if you question was to compress libraries and not just your own JavaScript code, it obviously gets really more involved, as you will need for most of these tools to export the symbols that should not be renamed or stripped. Most decent compressors will remove functions that they think are unused - often the case in a library, if not bound to a project, obviously - and change the names to make them shorter and use less characters - also a problem as you obviously want a public API to not be tampered with.

现在,如果您提出的问题是压缩库而不仅仅是您自己的JavaScript代码,那么它显然会更加复杂,因为您需要大多数这些工具来导出不应重命名或剥离的符号。最理想的压缩器将删除他们认为未使用的函数 - 通常是库中的情况,如果没有绑定到项目,显然 - 并更改名称以缩短它们并使用更少的字符 - 这也是一个问题,因为你显然想要公开API不会被篡改。

You can find other threads on this topic as well and find information in the tools' support documentation. You may also want to have a look at JSBuilder2, some sort of pendant to Dojo's Build tool (so, using ShrinkSafe or Closure Compiler) for ExtJS (using the YUI compressor).

您还可以在此主题中找到其他主题,并在工具的支持文档中查找信息。您可能还想看看JSBuilder2,它是Dojo的Build工具的一些吊坠(因此,使用ShrinkSafe或Closure Compiler)用于ExtJS(使用YUI压缩器)。

(Sorry, being a new SO user, I cannot add more than one link so I cannot link directly to the tools.)

(对不起,作为新的SO用户,我无法添加多个链接,因此无法直接链接到工具。)

EDIT: regarding the concerns expressed in some answers that compression might introduce bugs and that it makes debugging easier as the code is not mangled: yes, it's a valid concern. However:

编辑:关于在一些答案中表达的担忧,压缩可能会引入错误,并且由于代码没有被破坏,它使调试变得更容易:是的,这是一个有效的问题。然而:

  • you will get a very significant improvement in terms of bandwidth if you use a minifier, even with gzip compression activated (and you can learn to leverage gzip compression by making the compressor's life easier
  • 如果使用缩放器,即使激活了gzip压缩,你的带宽也会得到非常显着的改善(你可以通过让压缩器的生活变得更轻松来学习利用gzip压缩
  • you should just taste your code in debug and production mode to ensure the behavior is identical. I mean, it's part of your job as well...
  • 您应该在调试和生产模式下品尝您的代码,以确保行为完全相同。我的意思是,这也是你工作的一部分......
  • some of these compressors have been around for a while and won't really introduce bugs into your code. They're really just re-organizing things and substituting strings, really.
  • 其中一些压缩器已存在一段时间,并不会真正在您的代码中引入错误。他们真的只是重新组织事物并取代字符串。
  • some compressors (for instance the dojo build system) come with options to allow you to produce both a compressed and an uncompressed output, so that you can then enable different modes for debugging and production, using query parameters for instance.
  • 一些压缩器(例如dojo构建系统)提供了允许您生成压缩和未压缩输出的选项,以便您可以使用查询参数启用不同的调试和生成模式。

#4


12  

I don't minimize JavaScript at all: gzip compression is good enough for me and has the additional benefit that error messages will still be useful.

我根本没有最小化JavaScript:gzip压缩对我来说足够好,并且还有一个额外的好处,即错误消息仍然有用。

#5


11  

I too use YUI Compressor. I have an ant task like this that I use in my projects:

我也使用YUI Compressor。我在我的项目中使用了这样的ant任务:

<!--
YUI Compressor tasks 
http://www.julienlecomte.net/yuicompressor/README
-->
<property name="yuicompressor.jar"
           value="C:/devlibs/yuicompressor-2.2.4/build/yuicompressor-2.2.4.jar"/>

<target name="js.compress">
    <!-- Create min directory under js direcrtory if it doesnt exist -->
    <mkdir dir="${js-directory}/min" />

    <apply verbose="true" executable="java" parallel="false" failonerror="true">
        <fileset dir="${js-directory}" includes="*.js"/>
        <arg line="-jar"/>
        <arg path="${yuicompressor.jar}"/>
        <srcfile/>
        <arg line="-o"/>
        <mapper type="glob" from="*.js" to="${js-directory}/min/*-min.js"/>
        <targetfile/>
    </apply>
</target>

#6


5  

UglifyJS is a new one.

UglifyJS是一个新的。

UglifyJS compresses better than YUI Compressor and just about on par with the Google Closure Compiler. For example, the compressed version of jQuery from the Google Closure Compiler is only 403 bytes smaller than the version produced by UglifyJS - impressive! UglifyJS is also the fastest to run by a long shot, beating Closure by over 6 seconds!

UglifyJS比YUI Compressor压缩得更好,与Google Closure Compiler差不多。例如,来自Google Closure Compiler的jQuery的压缩版本仅比UglifyJS生成的版本小403字节 - 令人印象深刻! UglifyJS也是最快的一次击球,击败Closure超过6秒!

Additionally, the code produced by UglifyJS is safer than the code that Closure generates. For example, Closure doesn’t know how to deal with eval or with{} - it just logs an error and continues to rename variables anyway. This, obviously, leads to broken code. UglifyJS does not have this problem.

此外,UglifyJS生成的代码比Closure生成的代码更安全。例如,Closure不知道如何处理eval或使用{} - 它只记录错误并继续重命名变量。显然,这会导致代码损坏。 UglifyJS没有这个问题。

More information can be found here: http://badassjs.com/post/971960912/uglifyjs-a-fast-new-javascript-compressor-for-node-js

更多信息可以在这里找到:http://badassjs.com/post/971960912/uglifyjs-a-fast-new-javascript-compressor-for-node-js

#7


4  

Dean Edward's packer achieves some pretty good compression ratios. It has command line implementations which allows it to be used in a continuous integration process.

Dean Edward的打包机实现了一些非常好的压缩比。它具有命令行实现,允许它在持续集成过程中使用。

#8


4  

Google's closure tools

谷歌的关闭工具

You can map the minified version to the regular source code for debugging in Firebug with their add-on.

您可以将缩小版本映射到常规源代码,以便在Firebug中使用其附加组件进行调试。

#9


3  

I have tried YUI compressor before, but it gives me error message.

我之前尝试过YUI压缩器,但它给了我错误信息。

I suggest using JSMIN to minify your javascript:

我建议使用JSMIN来缩小你的javascript:

http://www.crockford.com/javascript/jsmin.html

http://www.crockford.com/javascript/jsmin.html

#10


3  

Here's a solution from Microsoft that you can integrate into Visual Studio to minify the files automatically when you build your project.

这是Microsoft的一个解决方案,您可以将其集成到Visual Studio中,以便在构建项目时自动缩小文件。

To Install:

安装:

Download the msi from : http://aspnet.codeplex.com/releases/view/40584

从http://aspnet.codeplex.com/releases/view/40584下载msi

You may need to restart your computer after its finished.

完成后,您可能需要重新启动计算机。

To Use:

使用方法:

Edit your .csproj file and include the following at the end of the file (but before the </Project> tag):

编辑.csproj文件并在文件末尾包含以下内容(但在 标记之前):

<Import Project="$(MSBuildExtensionsPath)\Microsoft\MicrosoftAjax\ajaxmin.tasks" />

<Target Name="AfterBuild">
    <ItemGroup>
        <JS Include="**\*.js" Exclude="**\*.min.js;Scripts\*.js" />
        <CSS Include="**\*.css" Exclude="**\*.min.css" />
    </ItemGroup>
    <AjaxMin 
    JsSourceFiles="@(JS)"
    JsSourceExtensionPattern="\.js$"
    JsTargetExtension=".min.js"
    CssSourceFiles="@(CSS)"
    CssSourceExtensionPattern="\.css$"
    CssTargetExtension=".min.css"/>
</Target>

Now when you build your project, all CSS and js files that don't end in .min.js, .min.css will be minified (See the "Exclude" attribute to exclude other files from being minified).

现在,当您构建项目时,所有未以.min.js,.min.css结尾的CSS和js文件将被缩小(请参阅“排除”属性以排除其他文件被缩小)。

#11


1  

http://code.google.com/p/jsmin-php/

http://code.google.com/p/jsmin-php/

Good old Doug Crockford :-) The beauty of this is that with cache control you can get somelovely automated compression only when it is required. Or in one of my projects I just output the compressed/gzipped files and delete them when I make a change. For a development environment, I just dont' call the minification script.

好老道格克罗克福德:-)这样做的好处在于,通过缓存控制,只有在需要时才能获得一些自动压缩。或者在我的一个项目中,我只输出压缩/ gzip文件,并在进行更改时删除它们。对于开发环境,我只是不称之为缩小脚本。

#12


0  

I use a simple (3-4 line) wrapper script around JavaScript::Minifier::XS.

我在JavaScript :: Minifier :: XS周围使用了一个简单的(3-4行)包装器脚本。

#13


0  

Here is an article which described how to use YUI Compressor for minimizing files during build: Compressing JS files as part of your build process

这篇文章描述了如何使用YUI Compressor在构建期间最小化文件:压缩JS文件作为构建过程的一部分

#14


0  

I use perl's JavaScript::Minifier. It works pretty well and you can e.g. replace some phrases using perl.

我使用perl的JavaScript :: Minifier。它工作得很好,你可以,例如用perl替换一些短语。

#15


0  

http://caja.appspot.com/tools/index does all three of HTML/CSS/JS.

http://caja.appspot.com/tools/index完成了所有三个HTML / CSS / JS。

#16


0  

https://jawr.dev.java.net/ is excellent for minification and versioning

https://jawr.dev.java.net/非常适合缩小和版本控制

#17


0  

There is a very good online compressor:

有一个非常好的在线压缩机:

http://javascriptcompressor.com/

http://javascriptcompressor.com/

You can also shrink variables, if you want even more compresed.

如果你想要更加复杂,你也可以缩小变量。

Hope it helps

希望能帮助到你