如何缩小 jquery 文件?
我正在使用 jquery,并且有几个不提供缩小版本的插件。所以我想采用完整版本并缩小它,但我发现所有网站都输入了 JavaScript,它缩小了它,从而破坏了插件。
就像它必须删除一些东西,因为我收到语法错误。
那么有人有一个好的我可以使用吗?
I am using jquery and I got a couple plugins that don't offer a minified version. 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.
Like it must strip something out because I get a syntax error.
So anyone got a good one that I can use?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
如果您熟悉 Java,您还可以使用 YUI 压缩器 来缩小 JS(和 CSS)文件你自己。我们在这里也使用它并且效果很好。
If you're familiar with Java you could also use YUI compressor to minify JS (and CSS) files yourself. We use it here as well and it works great.
Javascript Compressor Rater
我相信它通过 rhino 运行 js 并输出之前发现的任何错误,之后你可以选择最适合您的一种。
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.
这可能是因为一个或多个文件没有尾随分号,这通常很好,但我认为会导致缩小问题。或者,您可能会遇到正则表达式文字的问题。你用什么压缩器?
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?
如果您将插件压缩为单独的文件,则该过程可能会重命名属于 jQuery API 一部分的符号,因为压缩器不知道交互。
If you are minfying the plugins as separate files, the process may be renaming a symbol that is part of the jQuery API, because the minifier is not aware of the interaction.
ASP.net 团队发布了一个免费工具,使您能够通过减小 JavaScript 文件的大小来提高 Ajax 应用程序的性能。
这个新工具被命名为 Microsoft Ajax Minifier。详细信息在这里:
有关 Ajax 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.
The new tool is named the Microsoft Ajax Minifier. Deatails here:
Deatails about Ajax Minifier
Download it here
Download link
如果您的服务器上有 PHP5 和 Zlib,那么请尝试这个! http://code.google.com/p/minify/
我用它来组合jQ、jQ 插件、jQ-UI 和自定义站点应用程序客户端代码集成到单个文件中。
然后,我将该 JS 文件和一个小的特定于页面的 JS 文件(带有 onload 等)加载到每个页面上。
它工作得很好......而且它还可以处理 CSS。
没有它我不会离开家。 (这只是一个说法:)
If you have PHP5 and Zlib on your server, then try this one! 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.
I then load that JS file and a small page-specific JS file (with onload, etc) onto each page.
It works well...and it also handles CSS.
I don't leave home without it. (that's just a saying :)
这可能是一个分号问题。我发现 Microsoft 的 AjaxMin 是一个非常合理的工具,并且易于定制。
您可能想查看 PackScript - http ://danderson00.blogspot.com.au/2013/01/packscript-next- Generation-build-for-web.html
It's likely to be a semicolon issue. I find Microsoft's AjaxMin is a pretty reasonable tool that's easy to customise.
You might like to check out PackScript - http://danderson00.blogspot.com.au/2013/01/packscript-next-generation-build-for-web.html