使用 YUICompressor 组合 JS 文件导致错误

发布于 2024-08-19 00:44:52 字数 234 浏览 1 评论 0原文

我使用 YUI Compressor 组合多个 js 文件。该命令成功运行并正确输出组合文件。

然而,当我将页面指向它时,它似乎无法正确读取,并且我在 Javascript 错误控制台中收到此错误。

YAHOO is not defined

我尝试使用 --nomunge 和 --preserve-semi 选项,但仍然遇到相同的错误。

有什么想法吗?

I'm combining multiple js files using YUI Compressor. The command works successfully and outputs a combined file properly.

When I point my page to it, however, it doesn't seem to be read properly and I get this error in the Javascript error console.

YAHOO is not defined

I've tried using the --nomunge and --preserve-semi options but still get the same error.

Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(3

橪书 2024-08-26 00:44:52

您确定在脚本之前包含 yahoo YUI js 文件吗?
变量 YAHOO 是在 yui.js 中定义的,因此在尝试运行任何使用该脚本的 javascript 之前,该脚本需要存在并加载。

are you sure you're including the yahoo YUI js file before your script?
the variable YAHOO is defined within yui.js, so that script needs to exist and be loaded before you attempt to run any javascript that uses it.

戴夫,

如果没有压缩文件的链接,很难知道问题是什么。

您可能还想将这些链接发布到 YUILibrary.com 上的专用 YUI 压缩机讨论论坛:

http://yuilibrary.com/forum/viewforum.php?f=94

压缩机的开发人员都在那里,还有一个由其他实现者组成的感兴趣的社区。

-埃里克

Dave,

Hard to know what the problem is without a link to the compressed file.

You may also want to post those links to the dedicated YUI Compressor discussion forum on YUILibrary.com:

http://yuilibrary.com/forum/viewforum.php?f=94

Compressor's developers are there, as well as an interested community of fellow implementers.

-Eric

呢古 2024-08-26 00:44:52

你尝试过 jslint 你的代码吗?

它可以帮助您检测 JS 错误
它通常可以集成在你的IDE中(我使用Textmate),并在你保存js文件时警告你。

一个穷人的选择是使用在线版本: http://www.jslint.com

另一种选择是使用jsmin等更软的压缩工具来调试问题。其中一个托管在此处
您压缩文件。运行你的应用程序,通常你的 JS 调试器会告诉你问题。

Did you try to jslint your code?

It may help you detect JS errors
It can usually be integrated in your IDE(I use Textmate), and warn you when you save your js file.

A poor man option is to use the online one at: http://www.jslint.com

Another option is to use a softer compression tool like jsmin to debug the problem. One is hosted here
You compress your files. Run your app, and usually your JS debugger will show you the problem.

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