Tuesday, July 22, 2008

Yahoo! User Interface (YUI) Library

Information About Yahoo! User Interface (YUI) Library

What is the YUI?

The Yahoo! User Interface (YUI) Library is a free collection of utilities and controls, written primarily in JavaScript, that has been produced by the expert developers at Yahoo! to make your life easier as a web developer or front-end user interface designer.
It consists of a series of JavaScript and CSS components that can be used to quickly and easily build the rich and highly interactive applications that today's web consumer expects and demands.
The premise of the library is simple; often when writing JavaScript, you'll come up with a function that works perfectly in one browser, yet badly (or worse, not at all) in alternative browsers. This means that you'll often need a set of different functions to do exactly the same thing in different browsers.
This can be done for some of the major browsers without too much difficulty using standard object detection methods within if statements. However, this can lead to massively increased script files and unwieldy code that takes longer to debug and troubleshoot, and longer to write in the first place.
The YUI wraps both sets of code up into one object that can be used programmatically with one constructor, so instead of dealing with different sets of code for different browsers, you deal with the library and it makes the different calls depending on the browser in use.
Another important aspect of the library that I should mention at this point is its respect for the Global Namespace. All objects created by the library and its entire code run within, and can only be accessed through, the YAHOO Global Namespace object. This means that the entire library, including every utility and every
control, and its numerous classes, create just one namespace object within the
Global Namespace.
The Global Namespace is the global collection of JavaScript object names, and it is very easy to litter it with potentially conflicting objects, which can become a problem when code is shared between applications. Yahoo minimises its impact on the Global Namespace and so shall we; all of the code that we'll write throughout the course of this book will reside within its own namespace object.
Essentially, the YUI is a toolkit packed full of powerful objects that enables rapid front-end GUI design for richly interactive web-based applications. The utilities provide an advanced layer of functionality and logic to your applications, while the controls are attractive pre-packed objects that we can drop onto a page and begin using with little customization.