Will choosing between jquery or YUI change the overall/high level design of your .js files or would it realistically only going to be the inner workings of your js functions due to the differences in framework API's? (i.e. how you access/traverse the DOM, selectors, built-in functions, firing events, etc.)
Will choosing between jquery or YUI change the overall/high level design of your .js files or would it realistically only going to be the inner workings of your js functions due to the differences in framework API's? (i.e. how you access/traverse the DOM, selectors, built-in functions, firing events, etc.)
Share Improve this question asked Jan 27, 2009 at 20:31 BlankmanBlankman 267k332 gold badges795 silver badges1.2k bronze badges4 Answers
Reset to default 5When you pare the stucture of both libraries:
YUI:
YAHOO.util.Dom.setStyle(['test', 'test2'], 'opacity', 0.5);
var opacity = YAHOO.util.Dom.getStyle('test2', 'opacity');
and jQuery:
$("#test, #test2").css("opacity", 0.5);
var opacity = $("#test2").css("opacity");
They look pretty similar.
So the general flow of the script should be about the same with both libraries.
The differences I see are in simplicity and length. I personally feel like jQuery makes more sense but if you don't mind the nuances of each I'm sure they can both fill your needs.
There isn't much difference in terms of architectural decisions between YUI and jQuery. A library like Google Web Toolkit (GWT) or Dojo might have significant impact on the way you architect because of their need to be piled.
On a side note I'd say that I prefer YUI to jQuery for exactly the same reasons as the other answer to this question. I find the style of jQuery to be obtuse, it's kind of like Perl. If you don't already know the syntax it's not clear what the meaning is. While YUI is a bit more verbose I find the code very easy to parse.
My disclaimer is that I work at Yahoo! though so I'm used to using YUI a lot, and mostly only tinker with jQuery for personal projects ;)
I would say that yui, and especially yui3 encourage and makes it easy to keep your code modular. You have the yui loader where you can pull in parts of your application on the fly, and you also have rich support for synthetic events that lets you decouple parts of your application a bit more.
You aren't forced to use these features, but if you do it can help you build more modular applications and aid code re-use.
jQuery is easier to learn as pared to YUI, Though there is no much more difference in architecture.