YUI Compressor 中 JQuery 文件的压缩问题

发布于 2024-07-11 23:18:25 字数 682 浏览 4 评论 0原文

我正在尝试使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

澉约 2024-07-18 23:18:25

它本身不是 YUI,而是 jcarouselLite js。 “float”是一个保留字。 需要将其放在引号中。 EG:

li.css({overflow: "hidden", "float": o.vertical ? "none" : "left"});

您自己的代码也存在类似问题。 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:

li.css({overflow: "hidden", "float": o.vertical ? "none" : "left"});

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.

雾里花 2024-07-18 23:18:25

我已经多次遇到过这个问题,因为“类”这个词。 如果您在服务器端使用 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/

夏九 2024-07-18 23:18:25

这里的其他答案回答了实际问题(保留字)。 但我通过 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.

可爱暴击 2024-07-18 23:18:25

就我而言,当 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!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文