index.mustache revision 72d545a3aacf73830ad019134a025794ed01ce1e
ec64bd3c5fc3ae34d64d6a13e4ea5433f3063a58Dav Glass<div class="intro">
ec64bd3c5fc3ae34d64d6a13e4ea5433f3063a58Dav Glass <p>The YUI module is the single core dependency for all YUI 3 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>
ec64bd3c5fc3ae34d64d6a13e4ea5433f3063a58Dav Glass <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>
ec64bd3c5fc3ae34d64d6a13e4ea5433f3063a58Dav Glass<p>The YUI Global object is provided by one of our seed files:</p>
ec64bd3c5fc3ae34d64d6a13e4ea5433f3063a58Dav Glass<h2 id="loader-seed">The Loader Seed</h2>
ec64bd3c5fc3ae34d64d6a13e4ea5433f3063a58Dav Glass<script src="http://yui.yahooapis.com/{{{yuiVersion}}}/build/yui/yui-min.js"></script>
ec64bd3c5fc3ae34d64d6a13e4ea5433f3063a58Dav Glass<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>
ec64bd3c5fc3ae34d64d6a13e4ea5433f3063a58Dav Glass<h2 id="base-seed">The Base Seed</h2>
ec64bd3c5fc3ae34d64d6a13e4ea5433f3063a58Dav Glass<script src="http://yui.yahooapis.com/{{{yuiVersion}}}/build/yui-base/yui-base-min.js"></script>
ec64bd3c5fc3ae34d64d6a13e4ea5433f3063a58Dav Glass<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>
ec64bd3c5fc3ae34d64d6a13e4ea5433f3063a58Dav Glass<!--h2 id="why">Why the namespace change?</h2>
ec64bd3c5fc3ae34d64d6a13e4ea5433f3063a58Dav Glass <li><strong>Backward Compatibility</strong>: With the change from `YAHOO` to `YUI` we are guaranteed not to break backward compatibility. This allows you to use both YUI 2 and YUI 3 on
ec64bd3c5fc3ae34d64d6a13e4ea5433f3063a58Dav Glass the same page without fear of breaking existing code.</li>
ec64bd3c5fc3ae34d64d6a13e4ea5433f3063a58Dav Glass <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.
ec64bd3c5fc3ae34d64d6a13e4ea5433f3063a58Dav Glass 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>
ec64bd3c5fc3ae34d64d6a13e4ea5433f3063a58Dav Glass <li><strong>Versioning</strong>: If another version of YUI is loaded on the page, it will not change objects used in
ec64bd3c5fc3ae34d64d6a13e4ea5433f3063a58Dav Glass existing YUI instances. Both versions of YUI will operate with the corresponding versions of the reqested YUI modules without impacting each other.</li>
ec64bd3c5fc3ae34d64d6a13e4ea5433f3063a58Dav Glass <li><strong>More Dynamic</strong>: With Loader built into the core, loading files when you need them just got easier.</li>
ec64bd3c5fc3ae34d64d6a13e4ea5433f3063a58Dav Glass <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>
ec64bd3c5fc3ae34d64d6a13e4ea5433f3063a58Dav Glass <li><strong>Event Normalization</strong>: With the new Event Facade, you get maximum event normalization for cleaner cross browser code.</li>
ec64bd3c5fc3ae34d64d6a13e4ea5433f3063a58Dav Glass<h2 id="core">YUI Core</h2>
ec64bd3c5fc3ae34d64d6a13e4ea5433f3063a58Dav Glass<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>
ec64bd3c5fc3ae34d64d6a13e4ea5433f3063a58Dav GlassYUI().use('node', function(Y) {
<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 `use`. 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 `use` method contains a shorthand reference for all modules on the page. It uses the `*` as the module name.</p>
comboBase: 'http://mydomain.com/combo?',
<a href="/yui/docs/api/classes/config.html">available in the API Docs</a>.
comboBase: 'http://mydomain.com/combo?',
<h3>YUI.GlobalConfig</h3>
Setting options to the `YUI.GlobalConfig` object, the implementor can configure every YUI
YUI.GlobalConfig = {
comboBase: 'http://mydomain.com/combo?',
<h3>YUI.applyConfig</h3>
The global `YUI.applyConfig()` method allows the implementor to configure every YUI instance
comboBase: 'http://mydomain.com/combo?',
comboBase: 'http://mydomain.com/combo?',
<a href="modules.html">You can view a full list of modules here.</a>
<h2 id="yuiadd">Creating Custom Modules with YUI.add</h2>
<p>`YUI.add` is a static global method that is
`YUI.add` is executed. It receives the YUI instance
the <a href="http://yuilibrary.com/projects/builder">YUI Build Tool</a>
by YUI when `YUI.add` 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 `use` attribute
YUI.add('mymodules-mod1', function(Y) {
Y.namespace('mynamespace');
Y.mynamespace.Mod1 = function() {
<h2 id="nodejs">Using YUI on Node.js</h2>
<p>As of 3.5.0, YUI runs natively on <a href="http://nodejs.org/">Node.js</a> and comes with an official <a href="http://search.npmjs.org/#/yui">npm</a> package for easy installation.</p>
<p><a href="loader.html">Loader</a>'s functionality is now built into the YUI Global Object
<p>You can find <a href="loader.html">more information about Loader here</a>.</p>
<h2 id="Lang">Y.Lang</h2>
<p>`Y.Lang` contains JavaScript language utilities and extensions that are used in the YUI library.