是否有任何可用的 jQuery 构建针对与 underscore.js 一起使用进行了优化?
我在我的个人项目中使用 jQuery 和 underscore.js,我喜欢这两个框架。问题在于它们在功能上严重重叠。
例如有$.each
和_.each
,$.extend
和_.extend
,$.isArray
和 _.isArray
等等。两次使用所有这些方法并没有什么意义,所以我正在寻找没有这些方法的 jQuery 版本。
有可用的 jQuery 构建吗?
由于语义原因,我宁愿在下划线对象上使用这些方法,而不是在 jQuery 对象上(jQuery 用于 DOM、AJAX 等,Underscore 用于辅助函数),但我也对优化的 underscore.js 版本感到非常满意!< /em>
I'm using jQuery and underscore.js for my personal project and I love both frameworks. The problem is that they heavily overlap at functionality.
For example there are $.each
and _.each
, $.extend
and _.extend
, $.isArray
and _.isArray
and so on. It doesn't really make sense to have all of those methods twice so I'm looking for a jQuery version without those methods.
Is there any jQuery build available for this?
I rather want those methods at the underscore object than the jQuery object due semantics, (jQuery for DOM, AJAX etc. and Underscore for helper functions), but I would also be very happy with an optimized underscore.js version!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
jQuery 在自己的代码中到处使用这些方法。 (有时有特殊的未记录行为)
您将无法轻松删除它们。
不用担心;代码重复并没有那么糟糕,而且比维护 jQuery 的自定义版本要好得多。
jQuery uses those methods all over the place inside its own code. (sometimes with special undocumented behaviors)
You won't be able to remove them easily.
Don't worry about it; the code duplication isn't so bad, and it's much better than maintaining a custom version of jQuery.
您可能会幸运地尝试 JQuip。该项目的目标是开发一个更小、更模块化的 jQuery。查看他们的库构建器,您可以在其中挑选您需要的内容并忽略您不需要的内容。
我不确定你的项目需求,但听起来你正在用 jQuery 补充 underscore.js 。 jQuip 可能会帮助减少您不需要 jQuery 带来的臃肿。
祝你好运!
You might have some luck trying out JQuip. The project's goal is to develop a smaller, more modular jQuery. Check out their library builder where you can pick and choose what you need and leave out what you don't.
I'm not sure about your project needs, but it sounds like you're supplementing underscore.js with jQuery. jQuip might help by reducing the bloat you otherwise wouldn't need from jQuery.
Good luck!
我不会担心代码重叠,特别是如果您使用 google jquery 托管,您的访问者/用户可能已经缓存了它,并且在这一切的宏伟计划中这并不重要。
我看不出让库保持最新以减少这种性质的重叠有什么意义。
I wouldn't worry about the code overlap, especially if you utlize google jquery hosting, your visitor/user might already have it cached and it will not matter much in the grand scheme of it all.
I can't see a point of keeping a library up to date to reduce overlap of this nature.
您可以考虑使用 http://sizzlejs.com/,它是 JQuery 的选择器引擎。您不会获得所有 DOM 操作的内容,也不会获得 AJAX。
另外,我还没有亲自尝试过;但 EnderJS 看起来很有前途。
You can consider using http://sizzlejs.com/, which is JQuery's selector engine. You're not gonna get all of the DOM manipulation stuff, nor AJAX.
Also, I haven't personally tried it; but EnderJS looks promising.