2 Copyright (c) 2010, Yahoo! Inc. All rights reserved.
3 Code licensed under the BSD License:
4 http://developer.yahoo.com/yui/license.html
8 YUI.add('loader-rollup', function(Y) {
11 * Optional automatic rollup logic for reducing http connections
12 * when not using a combo service.
18 * Look for rollup packages to determine if all of the modules a
19 * rollup supersedes are required. If so, include the rollup to
20 * help reduce the total number of connections required. Called
21 * by calculate(). This is an optional feature, and requires the
22 * appropriate submodule to function.
27 Y.Loader.prototype._rollup = function() {
28 var i, j, m, s, r = this.required, roll,
29 info = this.moduleInfo, rolled, c, smod;
31 // find and cache rollup modules
32 if (this.dirty || !this.rollups) {
35 if (info.hasOwnProperty(i)) {
36 m = this.getModule(i);
37 // if (m && m.rollup && m.supersedes) {
44 this.forceMap = (this.force) ? Y.Array.hash(this.force) : {};
47 // make as many passes as needed to pick up rollup rollups
51 // go through the rollup candidates
52 for (i in this.rollups) {
53 if (this.rollups.hasOwnProperty(i)) {
54 // there can be only one, unless forced
55 if (!r[i] && ((!this.loaded[i]) || this.forceMap[i])) {
56 m = this.getModule(i);
57 s = m.supersedes || [];
60 // @TODO remove continue
67 // check the threshold
68 for (j = 0; j < s.length; j++) {
71 // if the superseded module is loaded, we can't
72 // load the rollup unless it has been forced.
73 if (this.loaded[s[j]] && !this.forceMap[s[j]]) {
76 // increment the counter if this module is required.
77 // if we are beyond the rollup threshold, we will
78 // use the rollup module
79 } else if (r[s[j]] && m.type == smod.type) {
81 roll = (c >= m.rollup);
93 // expand the rollup's dependencies
100 // if we made it here w/o rolling up something, we are done
109 }, '3.3.0' ,{requires:['loader-base']});