javascript jQuery 和 YUI(雅虎 ui)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9307485/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
jQuery and YUI (yahoo ui)
提问by AndrewMcLagan
So as i understand it jQuery is basically a framework for DOM manipulation as a higher abstraction layer then native javascript. Where as YUI (yahoo UI) library is a user interface widget library giving the developer a means to forget DOM manipulation and work more on business logic.
因此,据我所知,jQuery 基本上是一个用于 DOM 操作的框架,作为比原生 javascript 更高的抽象层。YUI(雅虎 UI)库是一个用户界面小部件库,它为开发人员提供了一种方法来忘记 DOM 操作并更多地处理业务逻辑。
Is that right?
是对的吗?
My Question: Is there any serious performance issues with including both libraries? and how does YUI compare to jQuery UI?
我的问题:包含这两个库是否存在严重的性能问题?YUI 与 jQuery UI 相比如何?
采纳答案by danjah
UPDATE
更新
The YUI framework was deprecated in August 2014
YUI 框架已于 2014 年 8 月弃用
I'll leave it to the jquery pros to spell out the best comparison points, but I use YUI in projects both small and large. YUI is structured so that you only need include the modular functionality you need, down to the grainiest level, including the ability to roll your dependencies all back up into just the right package.
我会把它留给 jquery 专家来说明最好的比较点,但我在大小项目中都使用 YUI。YUI 的结构使您只需要包含您需要的模块化功能,直到最细粒度的级别,包括能够将您的依赖项全部回滚到正确的包中。
YUI is fantastic for DOM manipulation, io, widgets, the works really. Go with YUI3, if you find YUI2 widgets you want/need, they have 'YUI2-in-3'.
YUI 非常适合 DOM 操作、io、widgets,真的很好用。使用 YUI3,如果您找到想要/需要的 YUI2 小部件,它们有“YUI2-in-3”。
In addition, one (probably more) of YUI's core contributors, Dav Glass, has done some awesome work on getting YUI3 on the server - so you essentially have the same framework doing back end grunt work, and the same dependencies doing the front end magic.
此外,YUI 的核心贡献者之一(可能更多),Dav Glass,在将 YUI3 安装到服务器上做了一些很棒的工作——所以你基本上有相同的框架来做后端工作,以及相同的依赖项做前端魔术.
YUI's seed inclusion system is very easy to get started with too, sample code:
YUI 的种子包含系统也很容易上手,示例代码:
<script src="http://yui.yahooapis.com/3.4.1/build/yui/yui-min.js"></script>
<script type="text/javascript">
YUI().use(['node','io'], function (Y) {
// node and io are ready now, do whatever you like. Need custom events, gesture support or animation? Add them to the array above.
});
</script>
There's my case for YUI, have fun with it :)
这是我的 YUI 案例,玩得开心 :)
Also, I have included both jquery and YUI on a couple of projects... I didn't notice anything detrimental, but with more YUI experience, I haven't needed to do that again.
此外,我在几个项目中同时包含了 jquery 和 YUI...我没有注意到任何有害的东西,但是有了更多的 YUI 经验,我不需要再这样做了。
回答by Mouna Cheikhna
jQuery
jQuery
$ DOM selection is powerful and works like magic.
jQuery code is usually very concise; helper functions exist for anything trivial (and non-trivial, even).
The plugin library is extensive and offers quick functionality.
jQuery is amazing for smaller sites and it's easy to pick up for new users , which is why it has such a large community.
immediate results with less learning curve.
$ DOM selection 是强大的并且像魔法一样工作。
jQuery 代码通常非常简洁;任何微不足道的(甚至非微不足道的,甚至)都存在辅助函数。
插件库非常广泛,并提供快速的功能。
jQuery 对于较小的站点来说非常棒,而且新用户很容易上手,这就是它拥有如此庞大社区的原因。
以更少的学习曲线获得立竿见影的效果。
YUI
唯
Great documentation and examples, as well as support from Yahoo with tech talks and frequent updates.
Code written with YUI tends to be organized. At times it even feels Java-esque. Has a rich set of modules for things other than DOM manipulation - cookies, cache, history, i18n, etc.
Particularly through Gallery, YUI has gotten more open to external contributions
YUI specialy YUI3 requires at least basic skill with the language, and more if you really want to exploit it well and extend it.
YUI is a lot more adapted for well organized, modular code which can be reused.
很棒的文档和示例,以及来自雅虎的技术讲座和频繁更新的支持。
用 YUI 编写的代码往往是有组织的。有时它甚至感觉像 Java 风格。除了 DOM 操作之外,还有一组丰富的模块 - cookie、缓存、历史、i18n 等。
特别是通过 Gallery,YUI 对外部贡献更加开放
YUI 特别 YUI3 至少需要基本的语言技能,如果你真的想很好地利用它并扩展它,则需要更多。
YUI 更适合于组织良好的、可重用的模块化代码。
To see what YUI is capable of you can visit herefor examples of YUI2 , and herefor YUI3 galleries(which are IMO a bit similar to JQuery plugins ) .
要了解 YUI 的功能,您可以访问此处查看 YUI2 示例,以及此处查看 YUI3 库(IMO 有点类似于 JQuery 插件)。
You can refer this siteto compare YUI and jquery's speed .
你可以参考这个网站来比较 YUI 和 jquery 的速度。
IMO JQuery is a library , YUI is a framework and not a library. JQuery is good for small websites where you want to achieve a ‘WOW' factor in relative short time. But when you are building an application, you need a robust framework where you can integrate your own codes yui is better choice.
IMO JQuery 是一个库,YUI 是一个框架而不是一个库。JQuery 适用于您希望在相对较短的时间内实现“WOW”因素的小型网站。但是当你构建一个应用程序时,你需要一个健壮的框架来集成你自己的代码,yui 是更好的选择。
回答by danwellman
Don't use both libraries, your pages will load slower :)
不要同时使用这两个库,您的页面加载速度会变慢:)
jQuery is mostly for DOM manipulation and AJAX and works well with web pages/sites. YUI is more of a framework and works well with web applications. Although there is some cross-over; YUI can be used easily with smaller trivial sites and jQuery can be used to create large web apps (although usually it is combined with something else like Backbone or JavaScriptMVC for better code organisation)
jQuery 主要用于 DOM 操作和 AJAX,适用于网页/站点。YUI 更像是一个框架,可以很好地与 Web 应用程序配合使用。虽然有一些交叉;YUI 可以轻松地用于较小的琐碎站点,而 jQuery 可用于创建大型 Web 应用程序(尽管通常它会与诸如 Backbone 或 JavaScriptMVC 之类的其他东西结合使用以更好地组织代码)
If one doesn't give you all you need, use a different one
如果一个不能满足您的所有需求,请使用另一个