简体   繁体   English

如何缩小jquery文件?

[英]How to minify jquery files?

I am using jquery and I got a couple plugins that don't offer a minified version. 我正在使用jquery,我有一些不提供缩小版本的插件。 So I want to take the full version and minfiy it but all the sites I have found that you input your javascript and it minifies it breaks the plugin. 所以我想要完整版本和minfiy它,但我发现你输入你的JavaScript的所有网站,它缩小它打破插件。

Like it must strip something out because I get a syntax error. 就像它必须剥离一些东西,因为我得到一个语法错误。

So anyone got a good one that I can use? 所以任何人都有一个我可以使用的好的?

If you're familiar with Java you could also use YUI compressor to minify JS (and CSS) files yourself. 如果你熟悉Java,你也可以使用YUI压缩器来自己缩小JS(和CSS)文件。 We use it here as well and it works great. 我们也在这里使用它,效果很好。

Javascript Compressor Rater Javascript Compressor Rater

I believe it runs the js through rhino and outputs any errors found before hand, and after you can choose the one that works best for you. 我相信它通过rhino运行js并输出之前发现的任何错误,之后你可以选择最适合你的那个。

It's likely to be a semicolon issue. 这可能是一个分号问题。 I find Microsoft's AjaxMin is a pretty reasonable tool that's easy to customise. 我发现微软的AjaxMin是一个非常合理的工具,易于定制。

You might like to check out PackScript - http://danderson00.blogspot.com.au/2013/01/packscript-next-generation-build-for-web.html 您可以查看PackScript - http://danderson00.blogspot.com.au/2013/01/packscript-next-generation-build-for-web.html

It could be because one or more files don't have a trailing semi-colon, which is usually fine but I think causes problem on minification. 可能是因为一个或多个文件没有尾随分号,这通常很好,但我认为会导致缩小问题。 Alternatively you may have issues with regex literals. 或者,您可能遇到正则表达式文字的问题。 What minifier are you using? 你用什么缩放器?

如果您将插件作为单独的文件进行minfying,则该过程可能正在重命名作为jQuery API一部分的符号,因为minifier不知道该交互。

ASP.net team published a free tool that enables you to improve the performance of your Ajax applications by reducing the size of its JavaScript files. ASP.net团队发布了一个免费工具,通过减少JavaScript文件的大小,您可以提高Ajax应用程序的性能。 The new tool is named the Microsoft Ajax Minifier. 这个新工具被命名为Microsoft Ajax Minifier。 Deatails here: Deatails about Ajax Minifier Deatails在这里: 关于Ajax Minifier的Deatails

Download it here Download link 在此处下载下载链接

If you have PHP5 and Zlib on your server, then try this one! 如果您的服务器上有PHP5和Zlib,那么试试这个吧! http://code.google.com/p/minify/ http://code.google.com/p/minify/

I use it to combine jQ, jQ Plug-ins, jQ-UI, and custom site application client-code into a single file. 我用它将jQ,jQ插件,jQ-UI和自定义站点应用程序客户端代码组合到一个文件中。

I then load that JS file and a small page-specific JS file (with onload, etc) onto each page. 然后我将该JS文件和一个特定于页面的小文件(带有onload等)加载到每个页面上。 It works well...and it also handles CSS. 它工作得很好......它也处理CSS。

I don't leave home without it. 没有它,我不会离开家。 (that's just a saying :) (这只是一个说法:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM