YUI Loader and seed file changes, plus Loader tips and tricks
Back in early July, Dav Glass posted an article about changes to the Loader and seed files in 3.4.0. There were a few questions in the comments and some others in the forum and #yui channel on freenode IRC, so I wanted to get Dav on the horn for a public Q&A.
I don’t expect that will take the whole hour, though, so after that, we’re going to be talking about Loader best practices and tips and tricks. Depending on time, some things I’m hoping to cover are:
How to make Loader fetch non-YUI files
Setting up module groups, and the many advantages of using them
Hosting and pointing to your own combo service
How each config affects where Loader will look for your files
If you have burning questions about Loader, have a trick you want to share, or haven’t yet realized just how awesome Loader is, please join us!
Time & Details
This week we’re going to host the session entirely on Adobe Connect, including the audio. We’ll use the Connect chat to manage questions or use Connect’s built in audio support for more in-depth discussions.
We’ll be online in the Open Hours room from 10am to 11am PDT Thursday.
If you love YUI (and we hope you do!), please take a moment to nominate us for the
"https://www.packtpub.com/open-source-awards-home/">2011 Open Source Awards, sponsored by Packt Publishing. Be sure to point to our shiny new website at http://yuilibrary.com!
The YUI team has not one, but two announcements to share today. First, we have launched a completely revised YUILibrary.com. The new site is a ground up rewrite providing a unified destination for all YUI documentation, a cleaner UI, and more intuitive organization on top of a robust new architecture. Take some time to look around. We hope you’ll be very happy with what you see.
In addition, YUI 3.4.0 is now available on CDN as well as download. Some highlights of this release include:
App Framework (beta): YUI 3.4.0 marks the debut of the App Framework by Ryan Grove and Eric Ferraiuolo. The App Framework is a rollup of the Controller, Model, Model List, and View components that provides a simple MVC-style framework for writing single-page JavaScript applications. These components can be used separately or together to create anything from simple non-interactive views to rich applications with URL-based routing, data binding, and full client-server synchronization.
Calendar (beta): Allen Rabinovich has added Calendar to YUI 3′s collection of widgets in the 3.4.0 release. Calendar is a flexible widget that provides month-to-month navigation, single or multiple date selection, custom formatting and internationalization. It also introduces a novel approach to date filtering that uses nested rule sets, and a fully template-based rendering, which allows developers to quickly and easily customize it for a variety of uses.
Loader: The YUI Loader has undergone a significant update for 3.4.0 by Dav Glass, with a focus on improving performance. The seed file contains Loader and its meta-data which makes the loading of modules faster since all of its meta-data requirements are already on the page. Rollups have been removed from the system and allowRollup defaults to false in the Loader config. As a result,YUI will now only load the modules specified rather than additional modules included as part of a rollup. Finally, the build directory has been exploded and submodules have been removed from the core system reducing the number of iterations executed by Loader in the calculation of dependencies. You can refer to the blog post about Loader changes in 3.4.0 for more details.
Graphics (beta): Tripp Bridges introduces the Graphics module in YUI 3.4.0. This component provides a JavaScript API that allows you to create predefined shapes and free-form polygons with fill and stroke properties in a variety of formats. Based on the capabilities of the browser and device, Graphics will render the shapes using SVG, HTML, Canvas, or VML.
Panel (beta) and Widget: YUI intern Tilo Mitra spent another productive summer in California working on a rewrite of Panel. He has also made several enhancements to Widget including the conversion of Widget-autohide and Widget-modality from plugins to extensions, and the introduction of WidgetButtons, a new Widget extension that allows you to place css-styled buttons in the header and footer of any widget that implements standard module support.
ScrollView: Tilo has also enhanced ScrollView for 3.4.0 to support vertical paging and include a scrollview-list plugin to add CSS classnames to immediate list elements.
In addition to providing designs for YUILibrary.com, YUI developer and designer, Jeff Coniff, also contributed a number of items for the 3.4.0 release. Enhancements have been made to the design and rendering of some of the widgets for better appearance and usability on mobile devices. He has also put is artistic talents to work in the creation of a number of new examples such as the Complex Drawing: Violin example in Graphics.
In parallel with the 3.4.0 release, the new and improved YUILibrary.com site is going live! The new site is unified, better organized, and has a fresh look and feel.
Look for an upcoming post about the site details, but join the Open Hours Connect room this Thursday morning to get a first-look guided tour by Ryan Grove and the other folks that made this a reality. We’ll be talking about the site design, backend setup, future plans, community opportunities, and checking out all the new features we can cram into an hour, including the new API docs interface.
We’ve been working our tails off to get this thing ready to launch and we couldn’t be happier to see it finally make its home on yuilibrary.com. Come celebrate the inauguration, give feedback (good and bad), and learn ways you can help make the new site the best it can be for you and for the greater YUI community.
Time & Details
This week, we’re not going to use a conference bridge. Instead, we’re going to host the session entirely on Adobe Connect, including the audio. We’ll use the Connect chat to manage questions or use Connect’s built in audio support for more in-depth discussions.
We’ll be online in the Open Hours room from 10am to 11am PDT Thursday.
We’re going to follow up on the previous post about Search Direct. There’s a lot about Search Direct worth talking about, but for starters, the experience of getting the accessibility right is both interesting and important. Victor Tsaran and Caridy Patiño will join us on the call to talk about the project, review the implementation details, and answer any questions you have about Search Direct or accessibility best practices.
Time & Details
We’re changing the format this week. We’re going to try to host the session entirely on Adobe Connect. There will be no conference bridge to dial into. The audio will also be through Connect. We’ll use the Connect chat to manage questions.
In a stroke of irony, it turns out that Connect does not have good accessibility for blind participants, so we’ll be using Connect for screen sharing and the conference bridge for audio as usual. The connection details are:
Dial in to 1-888-371-8922 (Skype works great for non-US participants*)
Enter the attendee code 47188953#
Join the screen sharing session (this will prompt you to install the Adobe Connect plugin if this is your first time using it)
A few months ago we launched the first beta release of Search Direct. This new product explores the concept of real-time feedback, instantly delivering answers to the user with each keystroke. Given the diversity of Yahoo!’s audience, we wanted to make Search Direct as accessible as possible. Initially, we believed that this would be an easy task since this product would be based on YUI 3, a JavaScript library with accessibility baked into its DNA. Contrary to my expectations as an engineer, this task turned out to be more difficult than we anticipated.
Introducing Search Direct
Although Search Direct is built from the ground up using YUI’s component infrastructure, its most visibly prominent interface is based on the YUI AutoComplete widget which includes many accessibility features right out of the box. Suggestions related to a particular query are displayed in this autocomplete implementation. Search Direct also features a content panel, a.k.a. the rich panel, where suggestion-related content is displayed. The intention of the rich panel is to provide a direct answer to the user when a suggestion from the autocomplete list is selected.
A new set of suggestions is displayed in the list on every keystroke, and the first suggestion is selected by default. This default selection is called a soft selection. Soft selections and subsequent interactions with the suggestion list dictate the content that is rendered into the rich panel. In reality, things are a bit more complicated (performance optimizations, additional cache layers, etc), but for the sake of simplicity we can assume that this is the common workflow.
Accessibility features
In the quest for making Search Direct accessible, we looked at the implementation of Search Assistant, a technology that Yahoo! pioneered a few years back, as well as the native accessibility features of YUI.
After this investigation, three primary accessibility features were proposed for Search Direct:
Setting role and aria-* attributes on elements within the autocomplete widget, that need to be identified and processed by screen readers.
Using a hidden div that represents a live region (aria-live) to notify the user when something happens. E.g., the number of available suggestions, the selected suggestion, etc.
The plan was to notify the user of any changes in the Search Direct interface, and provide a set of keyboard shortcuts to navigate the following visual components:
Searchbox
Submit button
Suggestion list
Rich panel
Sounds like a breeze, right? Well, let’s take a step back.
The problem
What we have here are two asynchronous processes — one of them for updating the suggestion set and the other one for retrieving corresponding answers — and they’re both really fast. We’re talking about 250ms end to end. Since the interface is changing at such a rapid pace, keeping track of everything can be difficult for a screen reader user. It gets an order of magnitude more complicated when updates happen in an asynchronous, near real-time manner. Because the screen reader was being notified of every change in the interface, the resulting chatter made it difficult to make sense of what was going on.
Lacking an acceptable solution, we started collaborating with Yahoo!’s resident accessibility guru, Victor Tsaran (@vick08) to try and come up with something better.
The first time we watched Victor interact with Search Direct, it was immediately clear to me that a majority of his focus was on the rich panel instead of the suggestion list. This was a surprise for me, as we viewed the list as the “source of truth”. During one of our sessions, we had a stroke of luck when we happened to disable all the accessibility features of the list. As soon as the noise introduced by the list was cut out, Search Direct started to make sense to Victor!
How users of screen readers perceive Search Direct
After realizing that we were trying to solve the wrong problem, we went back to the original user story: “As a user, I can get an answer as I type”. Getting the answer across to the user was the priority. After redefining the problem, we concentrated our accessibility efforts on an implementation where the screen reader prioritized the rich panel content over the suggestion list.
For example, if the user types "miami wea", the screen reader will tell them two things:
It will then continue reading out the rest of the rich panel content. The user doesn’t need to know all 10 suggestions up front, every time the list updates. If they do want to know, the information is readily accessible via keyboard navigation.
To ensure that the suggestion list is adding value to the experience, we make sure that the first phrase in the rich panel is closely related to its corresponding suggestion. For instance, based on the previous example, "weather miami" is the first phrase in the rich panel for the suggestion: “miami weather”.
Victor Tsaran, of the Yahoo! Accessibility Lab, shows how it works on FireFox with the NVDA screen reader:
The screen reader experience for our application is easier to follow since we now only focus on the following two visual components:
Searchbox
Rich panel
Changes to the autocomplete list as a whole are no longer tracked, and the submit button is ignored since the user can always hit enter for the current query or use a keyboard shortcut (tilda access key: [control, alt or shift] + ~) to switch between the input element and the rich panel. These keyboard navigation options are revealed to the user when the searchbox is acknowledged by the screen reader.
From an engineering perspective, this change greatly simplified things. The amount of DOM manipulation in the most active component was drastically reduced, improving the overall performance of Search Direct. Here is an example of the implementation:
function SDAAria () {
var node = this._liveRegion = Y.Node.create('<div role="status" class="off-screen" aria-live="assertive"></div>');
// Create the ARIA live region...
Y.one('body').append(node);
// listening for aria:live messages to update the live region
this.on('aria:live', this._handlerMsg, this);
// listening for gossip:refresh to announce how many suggestions
this.on('gossip:refresh', this._handleGossipRefresh, this);
}
SDAAria.ATTRS = {
strings: {
valueFn: function () {
return Y.Intl.get('sd-aria');
}
}
};
SDAAria.prototype = {
_ariaSay: function (stringId, subs) {
var message = this.get('strings.' + stringId) || '';
this._liveRegion.setContent( subs ? Y.Lang.sub(message, subs) : message );
},
_handlerMsg: function (e) {
if (e.id) {
this._ariaSay(e.id, e.subs);
}
},
_handleGossipRefresh: function () {
var size = this.get('suggestions').size();
this._ariaSay( (size > 0 ? 'SUGGESTIONS' : 'NO_SUGGESTIONS'), {
n: size
});
}
};
Lessons learned
When creating an accessible interface, it’s important to ask the right questions. Making every bit of your application accessible may not be the right approach.
Request early feedback from users of screen readers — don’t assume that you have your bases covered until you get some user feedback. Utilizing every tool and feature at your disposal may not have the intended effect.
Users of screen readers may have difficulty keeping track of real-time updates, especially if screen readers are bombarded with notifications. In these scenarios, less can be more. Identify and focus on what is important for the user instead of trying to replicate the raw experience of the application for the screen reader.
About the author: Caridy Patiño, Principal Frontend for Yahoo! Search Direct. He has been a longtime YUI Contributor and creator of Bubbling Library YUI Extension, as well as guest blogger at YUIBlog.com sharing some of his extensive experience building high performance web applications. Loading strategies, event-driven architectures and SSJS are some of the subjects where Caridy spends most of his time these days.