与 Jquery 一起使用的 Javascript concat/minify 库?
我尝试过许多动态 Javascript 缩小/连接库,但它们似乎都有一个问题,即 $(document).ready() 命令中需要 Jquery 的任何内容最终都会显示“$ 未定义”,即使它们包含在要连接的文件列表中。
我可以通过将 Jquery 排除在连接之外(和 CUFON 以及任何其他依赖于 $(document).ready() 的东西)来解决这个问题,但这显然并不理想。
关于如何让它们愉快地一起玩,以便我可以将加载减少到 1 个文件,但仍然有 Jquery 可供需要它的脚本使用,有什么建议吗?
I've tried a number of dynamic Javascript minifying / concatenating libraries, but they all seem to have the problem that anything that requires Jquery in the $(document).ready() command ends up saying "$ is not defined", even if they're included in the list of files to be concatenated.
I can get around this by leaving Jquery out of the concatenation (and CUFON and anything else that relies on $(document).ready() ), but this is obviously not ideal.
Any suggestions on how to make them happily play together so I can reduce the loading to 1 file, but still have Jquery available to the scripts that need it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
经过进一步的研究,我发现 head.js 的效果很好 - 它只需要用 head.ready() 调用替换 $(document).ready() 调用,一切就可以愉快地一起进行了:-)
After some further research I found that head.js works a treat - it just requires replacing $(document).ready() calls with head.ready() calls and everything plays happily together :-)
我使用 此网站 进行静态 JavaScript 文件压缩。 YUI 压缩脚本从来没有遇到过任何问题。总是按预期工作。
但我确实使用了 jQuery 的缩小文件。我自己不会缩小它。我缩小了自己的插件和脚本,它们可以与 jQuery 一起使用。
为了简洁起见,我总是使用:
而不是:
I use this web site for static javascript file compression. Never had any problems with YUI compressed scripts. Always worked as expected.
But it's true I'm using jQuery's minified file. I don't minify it myself. I minify my own plugins and scripts and they work with jQuery.
And for the sake of brevity I always use:
instead of:
我已经使用 Microsoft 的 AjaxMin 成功缩小了 jQuery。这是 PackScript 开箱即用的缩小器,PackScript 是一个用于管理整个 Web 资源构建过程的出色工具。
看看 - http://danderson00 .blogspot.com.au/2013/01/packscript-next- Generation-build-for-web.html
I've successfully minified jQuery using Microsoft's AjaxMin. This is the minifier that is used out of the box by PackScript, an awesome tool for managing the whole web resource build process.
Check it out - http://danderson00.blogspot.com.au/2013/01/packscript-next-generation-build-for-web.html