onAvailable lets you run a piece of JavaScript once all the nodes it requires are available. Our first iteration just checked for the existence of the node, but that turned out to be a problem if the node was large and had several sub-nodes. A second iteration checked that the node existed and had a nextSibling. This meant that the node had completed loading and parsing and the browser was now on to the next node.
This implementation naturally needed polling of the DOM, but YUI's always been pretty smart about clubbing polling events together, and not doing too much at the same time.
Combined with the fact that you only need to load the YUI bootstrap code up front and let everything else load asynchronously, this can significantly reduce download time.
I only wish YUI 2 had a better syntax that might have made it more popular. You'll have to take the word of those of us who worked at Yahoo! at the time, it was a huge improvement over YUI 1, and YUI 3 is far more JavaScript like and far less Java like.
onAvailable lets you run a piece of JavaScript once all the nodes it requires are available. Our first iteration just checked for the existence of the node, but that turned out to be a problem if the node was large and had several sub-nodes. A second iteration checked that the node existed and had a nextSibling. This meant that the node had completed loading and parsing and the browser was now on to the next node.
This implementation naturally needed polling of the DOM, but YUI's always been pretty smart about clubbing polling events together, and not doing too much at the same time.
Combined with the fact that you only need to load the YUI bootstrap code up front and let everything else load asynchronously, this can significantly reduce download time.
I only wish YUI 2 had a better syntax that might have made it more popular. You'll have to take the word of those of us who worked at Yahoo! at the time, it was a huge improvement over YUI 1, and YUI 3 is far more JavaScript like and far less Java like.