YUI recommends YUI3.
YUI 2 has been deprecated since 2011. This site acts as an archive for files and documentation.
This documentation is no longer maintained.
This example shows using the Profiler on all methods in an object. It uses the YAHOO.util.Dom
object
as the object to be profiled.
Keep an eye on the Logger console at right to see the profiling information being reported.
To illustrate using the Profiler on objects, the YAHOO.util.Dom
object is registered for profiling. This means
that all of the methods on the object are being profiled. The two methods being called explicity are getElementsByClassName()
and addClass()
, although the Profiler will show that these methods use other methods on YAHOO.util.Dom
. To
illustrate their use, a number of demo elements are added to the markup:
The button is used to run the example. The function being called when the button is clicked is assigned using the
YUI Event Utility's on()
method:
The function begins be registering YAHOO.util.Dom
with the Profiler. Note that since this object exists in the
global scope, only one argument is necessary for registerObject()
. Then, the getElementsByClassName()
and addClass()
methods are called. After that, the full report is returned and the object is unregistered. The last
step is to output all of the information that was collected. Even though there's only two methods called explicitly in this example,
the profiled data indicates that several other methods on YAHOO.util.Dom
were called internally to accomplish the
tasks.
All YUI 2.x users should review the YUI 2.8.2 security bulletin, which discusses a vulnerability present in YUI 2.4.0-2.8.1.
Copyright © 2013 Yahoo! Inc. All rights reserved.