YUI Compressor 中 JQuery 文件的压缩问题
我正在尝试使用 YUI 压缩器缩小一些文件。 然而,我似乎在两行代码上遇到了错误,这阻止了压缩。 jcarouselLite 的 .js 文件包含 1 个错误,我自己的代码包含另一个错误。
我已经缩小了范围,在这两种情况下,看起来都是 jQuery 中使用的 float 属性造成的。 该行是:
li.css({overflow: "hidden", float: o.vertical ? "none" : "left"}); (jcarousellite)
$("#now-playing .js-kit-rating div:first").css({width: "80px", float: "right"}).addClass("clearing"); (own code)
通过运行 jCarouselLite 可以看到该错误的工作示例code 通过 YUI 压缩器,但基本上返回的错误是无效的属性 id。
有人在使用 YUI 压缩器时遇到过类似的问题吗?
I am trying to minify a few files with YUI compressor. However, I seem to be getting an error on 2 lines of code, which prevents compression. The .js file for jcarouselLite contains 1 error, and my own code contains the other.
I have narrowed it down and in both occasions it looks like the the float property used in jQuery is causing this. The line is:
li.css({overflow: "hidden", float: o.vertical ? "none" : "left"}); (jcarousellite)
$("#now-playing .js-kit-rating div:first").css({width: "80px", float: "right"}).addClass("clearing"); (own code)
A working example of the error can be seen by running the jCarouselLite code through the YUI compressor, but basically the error returned is invalid property id.
Has anyone had similar issues with the YUI compressor?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
它本身不是 YUI,而是 jcarouselLite js。 “float”是一个保留字。 需要将其放在引号中。 EG:
您自己的代码也存在类似问题。 YUI 正在尽力编译该 js,但会拒绝/警告您类似您找到的代码。 IMO 它正在做正确的事情。
It's not YUI per se, it's the jcarouselLite js. "float" is a reserved word. It needs to be put in quotes. EG:
Similar issue with your own code. YUI is trying its best to compile that js but will refuse/warn you of code like the one you found. IMO it's doing the right thing.
我已经多次遇到过这个问题,因为“类”这个词。 如果您在服务器端使用 YUI,它应该吐出它所抱怨的行号。
这是一个看起来相当全面的保留字列表。
http://mattsnider.com/languages/javascript/reserved-words-in- JavaScript/
I've run into this issue a few times with the word "class". If you're using YUI on the server side, it should spit out the line number it's complaining about.
Here's a list of reserved words that seems pretty comprehensive.
http://mattsnider.com/languages/javascript/reserved-words-in-javascript/
这里的其他答案回答了实际问题(保留字)。 但我通过 BundleTransformer 使用 YUI 并且它不输出行号,所以我有点迷失去哪里看。
为了加快查找关键字的过程,我开始寻找另一个工具。
这个在线 YUI 压缩器帮助我找到了有问题的属性名称。
The other answers here answer the actual problem (reserved words). But I am using YUI via BundleTransformer and it isn't outputting line numbers, so I was a little lost as to where to look.
To speed up the process of finding the keywords I went looking for another tool.
This online YUI compressor helped me find the problematic property name.
就我而言,当 YUI 无法压缩我的文件时,这是因为我的 js 文件中有“调试器”。 希望这可以节省其他人几个小时的调试时间!
in my case when YUI was unable to compress my files it was because I had the 'debugger' in the js file. Hope this saves someone else several hours of debugging!
我准备了一个用于更新 yui 压缩器的自定义版本
https://github.com/MrD0llaro/yuicompressor
和
https://github.com/MrD0llaro/yui-compressor-ant-task/< /a>
在新的 Jquery 3.5.1 上使用它
I have prepared a custom version for update yui compressor
https://github.com/MrD0llaro/yuicompressor
and
https://github.com/MrD0llaro/yui-compressor-ant-task/
for use it on new Jquery 3.5.1