Why YUI is my favorite Javascript framework and why it should be yours too!

Wednesday Jul 9 2008

I've been meaning to write this article for quite a long time. By now I can safely say I have extensive experience with various different Javascript frameworks and I can therefore now express my preference. Now before I get started the following: You may think I'm heavily biased because I happen to work for Yahoo! when it comes to my preference for . In a certain sense this is true, but not in the sense most people will think.

The only influence my job at Yahoo has had on all this is the simple fact that working there exposed me to how great YUI really is. This is something that a lot of you may not realise yet, for the simple reason that you've never REALLY looked at it. When looking around on the web for Javascript frameworks it never seemed to be the popular option. I don't have any numbers to back up this claim but for some reason I haven't seen all that many tutorial sites, open source projects using it or blogs writing about it when compared to JQuery, Prototype.js or even Dojo. In short: Yahoo made me get to know and fall in love with it.

Dark Matter Pro: a premium photoblog template.

Affiliate program available

Picking a framework to build Dark Matter

Since april 2008 I'm working on a fairly advanced photoblog template: Dark Matter. It provides a quite impressive amount of interactive functionality such as UI animations, AJAX commenting, a custom caching image browser carousel and much more. Before I started building this I had to choose which Javascript framework to base all this functionality on. Needless to say, I choose to use YUI. As you may know from the articles I wrote about it I quite like JQuery as well. JQuery is extremely easy to use, very widespread and has lots of community support as well as fans blogging about it. I love using JQuery for small bits of functionality and most important for fast prototyping of Javascript based functionality. For a long-term project with more complexity however, my vote goes to YUI.

So what's so great about YUI?

Let me explain a few reasons why I believe YUI is the framework of choice.

Debugging and Profiling

YUI offers extremely advanced and sophisticated debugging through the YUI logger control. There is no other Javascript framework offering tools that are this great while developing an application. Especially in IE where you cannot use Firebug this has proven to be extremely helpful.

Want to improve performance by finding bottlenecks in your code? YUI provides an excellent profiler.

Blistering fast framework hosting and serving of assets

YUI can be served from Yahoo's own CDN. There is pretty much nothing faster than this. Your hosting provider can't possibly beat the speed at which these files are served and in addition to that, because the files are hosted on another domain than your own you get some free extra parallel asset downloads!

Then there's the YUI loader. YUI loader allows loading of YUI component as they are needed. This means they will only be loaded when they're actually used. This further speeds up your site and prevents loading of unnecessary code on pages that don't use it.

While certain other JS libraries are now also served from a CDN thanks to Google, for YUI not just the core libraries are hosted on Yahoo's CDN but all widgets as well! So whatever component you want to use, speedy hosting is always available!

Excellent documentation

YUI is well supported and comes with a vast amount of examples and API documentation. For just about anything you need you'll be able to find a documented real-world example in the YUI examples section. The API documentation section is equally brilliant. It's all there, waiting for you to discover.

Web Standards and REAL Javascript

Now here comes the most important reason I love YUI.

Like I said before, I quite like JQuery for rapid prototyping and small things such as an accordion menu. It's pretty damn amazing how much you can do in JQuery with very few lines of code. As great this may be, I think this is also where it's core weakness lies. JQuery is almost a new language of it's own. It's very well possible to use JQuery to a fair extent without really understanding the language Javascript. This can of course lead to horrible code where a gazillion things are chained together resulting in unreadable code consuming vast amounts of memory. Not so much with YUI! While YUI offers me everything I need to get things done, it doesn't attempt to change the language or force me into patterns that don't look much like Javascript anymore. Maybe some will see this as a potential 'weakness' in YUI: One must actually understand Javascript in order to use it effectively. This may not be the way of the lazyweb but... it's worth it! The learning curve may be a bit steeper than with other frameworks but ... you will see an amazing return of investment!

Another great thing about YUI (at least, the core framework components) is the fact that it honours web standards in every possible way. It's born to do unobtrusive Javascript unlike some other frameworks that add all sorts of (horribly invalid) cruft to your markup. Yes, I'm looking at you, Dojo!

Using YUI made me understand much more about Javascript than I did before I was using it. It made me a much better programmer and come to the point where I can pretty much achieve anything I want in Javascript including writing custom widgets from scratch. It allows me to write highly maintainable code which is a joy to look back at without any 'WTF?' moments when looking at things I have done quite a while ago.

So, if you've never taken a closer look at YUI, I hope you now know what you're missing out on!

Now go check it out!.

bookmarking

Commentary

Join the discussion! Leave a comment through the comment form below!

Got something to add to this?

Feel free to leave a comment on this site. You can use Textile and Emoticons. Your email address is only used to show a gravatar. Please stay on-topic and use common decency. Spammers will be shot in front of a live studio audience.

If you plan on posting code, use pastebin please and post a URL to the code. The comment processing doesn't deal very well with code. Sorry for the inconvenience.

Human comment spammers: don't bother posting your crap here. Comments are moderated and I won't let any of your shit through.

Remember personal info?
Yes
No

Trackbacks

If you have an interesting related post on your own site you can leave a trackback. As they say: 'a little AJAX a day keeps the spammers away' which is why you'll have to click below to generate a trackback key. The key will be valid for 15 minutes and can be used only once.

 

  • Featured Links
RockySomewhere near the Orion NebulaBookalicio.usGolden Gate BridgeThames River BankJackie and mePimpin' it