13

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.

Is that right?

My Question: Is there any serious performance issues with including both libraries? and how does YUI compare to jQuery UI?

casperOne
  • 73,706
  • 19
  • 184
  • 253
AndrewMcLagan
  • 13,459
  • 23
  • 91
  • 158

3 Answers3

22

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.

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.

To see what YUI is capable of you can visit here for examples of YUI2 , and here for YUI3 galleries(which are IMO a bit similar to JQuery plugins ) .

You can refer this site to compare YUI and jquery's speed .

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.

mujaffars
  • 1,395
  • 2
  • 15
  • 35
Mouna Cheikhna
  • 38,870
  • 10
  • 48
  • 69
  • 4
    Nice comparison, also, there's some interesting reading to be had by John Resig here: http://www.quora.com/How-could-YUI3-improve-its-image-compared-to-jQuery-MooTools-etc – danjah Feb 16 '12 at 08:44
  • 3
    +1 for "JQuery is a library , YUI is a framework and not a library" – AndrewMcLagan Feb 17 '12 at 02:06
  • @Danjah: good link, John Resig makes a smart point when he says: "Simplicity is far harder to get right than building complex applications." – Marco Demaio Jan 25 '14 at 18:53
7

UPDATE

The YUI framework was deprecated in August 2014


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.

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'.

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's seed inclusion system is very easy to get started with too, sample code:

<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 :)

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.

AndrewMcLagan
  • 13,459
  • 23
  • 91
  • 158
danjah
  • 2,939
  • 2
  • 30
  • 47
  • Any idea how YUI 3 compares in performance? YUI 2 seems very poor in comparision to jq – AndrewMcLagan Feb 16 '12 at 09:45
  • I have no official benchmark links, they will exist I am sure, but I can tell you that YUI3's selector utility absolutely killed when compared to YUI2's. I did a bunch of basic tests on IE6 & 7, as they're of concern to me, and YUI3 outshone its predecessor. I'd say mix and matching YUI2-in-3 probably wouldn't do wonders for performance, but you may find you don't need to look back at all. I happen to have a deal of YUI2 code that wanted upgrading, so the option of YUI2-in-3 is a nicety. – danjah Feb 16 '12 at 10:23
  • 1
    Of interest might be: http://www.jsrosettastone.com/ which is a comparison of syntax, of sorts. Keep in mind that list seems to stop at YUI 3.0.0, where YUI is at 3.5 right now. – danjah Feb 16 '12 at 10:29
  • Hey team, just a note about this question - the YUI framework was deprecated in August 2014. – danjah Mar 09 '16 at 04:00
1

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)

If one doesn't give you all you need, use a different one

danwellman
  • 9,068
  • 8
  • 60
  • 88
  • dont get me wrong, but following you logic YUI would be more applicable to to web apps and jQuery to smaller sites no? – AndrewMcLagan Feb 16 '12 at 09:17
  • Size does not always denote complexity. But yes, jQuery is better suited to 'smaller' sites. See: http://blog.rebeccamurphey.com/on-jquery-large-applications – danwellman Feb 16 '12 at 09:43
  • 1
    Actually YUI can be very much used in 'smaller' sites. Just use SimpleYUI http://ericmiraglia.com/yui/demos/quickyui.php if you want less complexity. And similarly, you can use jQueryUI and Wijmo for larger sites built on jQuery. – juandopazo Feb 16 '12 at 14:31
  • Actually, yes, I said that in the second paragraph of my answer: "YUI can be used easily with smaller trivial sites" and "jQuery can be used to create large web apps". I am not saying YUI cannot be used for small sites or jQuery must be used for large apps. I don't understand why people are a) failing to actually read my answer, and b) taking the bits of my answer than they have read completely out of context. My answer was more about advising against using 2 libraries than it was about what either of the two libraries can/should be used for – danwellman Feb 16 '12 at 17:34