index.mustache revision 046ea4d1ee0f22d956cd360e1e0c0b275aa4bbd0
553N/A <p>The YUI module is the single core dependency for all YUI 3.x implementations. It must be included on all pages that use YUI — and it is the only dependency required to start writing YUI code. The YUI module contains loader functionality and a dependency calculator, allowing it to serve as a "seed" for your implementation. You provide the YUI module list you're using and the code that makes use of those modules; YUI will fetch all necessary components in a single, optimized HTTP request before executing your dependent code. While you may use some of the script- and CSS-loading facilities of the YUI module in your own implementation, this module's core purpose is to serve as a small seed from which complex, highly modular implementations can grow.</p>
0N/A <p>The YUI module creates a global YUI object. This object is instantiable, and it is used to create YUI instances to which are bound specific functional modules. A page can share a single YUI instance or can use different, insular instances for each piece of functionality on the page.</p>
0N/A<p>This seed file contains everything you need to fetch/use YUI core modules. It includes our dynamic script loader as well as all of the meta-data required to load additional YUI modules.</p>
553N/A<script src="http://yui.yahooapis.com/{{{yuiVersion}}}/build/yui-base/yui-base-min.js"></script>
0N/A<p>This seed file contains the core items you need to use YUI core modules. It also includes the capability to fetch our dynamic script loader. <em>This seed was our old `yui.js`</em></p>
0N/A <li><strong>Backward Compatibility</strong>: With the change from <code>YAHOO</code> to <code>YUI</code> we are guaranteed not to break backward compatibility. This allows you to use both YUI 2.x and YUI 3.x on
0N/A <li><strong>Sandboxing</strong>: The new YUI Global Object is now smarter than ever, allowing you to create an instance of YUI in your own namespace and only load the modules that you need.
0N/A It makes it easier for multiple developers to work on different parts of the page with different modules with less worry of them stepping on each other's toes.</li>
0N/A <li><strong>Versioning</strong>: If another version of YUI is loaded on the page, it will not change objects used in
0N/A existing YUI instances. Both versions of YUI will operate with the corresponding versions of the reqested YUI modules without impacting each other.</li>
0N/A <li><strong>More Dynamic</strong>: With Loader built into the core, loading files when you need them just got easier.</li>
0N/A <li><strong>Selector Powered</strong>: Using Selector as its base for node handling, you now get more power and ease of use for free.</li>
0N/A <li><strong>Event Normalization</strong>: With the new Event Facade, you get maximum event normalization for cleaner cross browser code.</li>
0N/A<p>The YUI Global Object is an instantiatable object that allows you to create as many YUI instances as you need. Each completely configurable and loaded with only the modules that you need.</p>
Y.one('#demo');
<p>The `use` method allows you to choose the modules that you want loaded into your YUI instance. You can pick and choose what you need, you don't have to load everything that was included on the page.</p>
// Y.DD is available
// Y.Anim is available
// Y.DD is NOT available
// Y.Anim is available
<p>You can pass a function in as the last argument to <code>use</code>. This function will execute after the YUI instance loads all the modules.
<p>The callback method has one argument passed, the YUI instance that we are dealing with. In this function you know that all the modules have been loaded and it's ok to use them.</p>
// Y.Anim is available
<p>The <code>use</code> method contains a shorthand reference for all modules on the page. It uses the <code>*</code> as the module name.</p>
<td>IO (XHR/XDR)</td><td>io</td>
<h2 id="yuiadd">Creating Custom Modules with YUI.add</h2>
<p><code>YUI.add</code> is a static global method that is
<code>YUI.add</code> is executed. It receives the YUI instance
the <a href="http://yuilibrary.com/projects/builder">YUI Build Tool</a>
by YUI when <code>YUI.add</code> executes -- it is used to fill in the
describes a module/submodule relationship -- when you build a YUI
YUI.add wrapped content for each submodule. The <code>use</code> attribute
YUI.add('mymodules-mod1', function(Y) {
Y.namespace('mynamespace');
Y.mynamespace.Mod1 = function() {
base: '../../build/', // the base path to the YUI install. Usually not needed because the default is the same base path as the yui.js include file
combine: true, // use the Yahoo! CDN combo service for YUI resources, default is true unless 'base' has been changed
fullpath: 'http://yui.yahooapis.com/combo?2.7.0/build/yahoo-dom-event/yahoo-dom-event.js&2.7.0/build/datasource/datasource-min.js'
fullpath: 'http://bluesmoon.github.com/yui-flot/yui.flot.js',
comboBase: 'http://yui.yahooapis.com/combo?',
path: "animation/animation.js",
<li>`comboBase`: The YUI combo service base dir. Ex: http://yui.yahooapis.com/combo?</li>
'replaceStr': "-debug.js"
<li>`combine`: Use the YUI combo service to reduce the number of http connections required to load your dependencies</li>
<li>`force`: A list of modules that should always be loaded when required, even if already present on the page</li>
<li>`insertBefore`: Node or id for a node that should be used as the insertion point for new nodes</li>
<li>`timeout`: number of milliseconds before a timeout occurs when dynamically loading nodes. in not set, there is no timeout</li>
<li>`fullpath`: required if path isn't specified, the full path to the script. "base" will not be used to build the url</li>
<li>`after`: array of modules the components which, if present, should be sorted above this one</li>
<li>`lang`: array of BCP 47 language tags of languages for which this module has localized resource bundles</li>
<li>`when` - specifies the load order of the conditional module with regard to the position of the trigger module.
<li>`groups`: in 3.1.0, the groups config was added as an enhancement over the 'modules' config. Each group can
the <code>base</code>, <code>comboBase</code>, <code>root</code>, <code>combine</code>, and <code>modules</code>
<p><code>Lang</code> contains JavaScript language utilities and extensions that are used in the YUI library.
Y.Lang.isArray([1, 2]);
Y.Lang.isArray({"one": "two"});
return Y.Lang.isArray(a);
Y.Lang.isBoolean(false);
Y.Lang.isBoolean(1);
Y.Lang.isBoolean("true");
Y.Lang.isNull(null); // true
Y.Lang.isNull(undefined); // false
Y.Lang.isNull(""); // false
Y.Lang.isFunction(function(){}); // true
Y.Lang.isFunction({foo: "bar"}); // false
Y.Lang.isNumber(0);
Y.Lang.isNumber(123.123);
Y.Lang.isNumber("123.123");
Y.Lang.isNumber(1/0);
Y.Lang.isObject({});
Y.Lang.isObject(function(){});
Y.Lang.isObject([1,2]);
Y.Lang.isObject(1);
Y.Lang.isObject(true);
Y.Lang.isObject("{}");
Y.Lang.isString("{}"); // true
Y.Lang.isString({foo: "bar"}); // false
Y.Lang.isString(123); // false
Y.Lang.isString(true); // false
Y.Lang.isUndefined(undefined); // true
Y.Lang.isUndefined(false); // false
Y.Lang.isUndefined(null); // false