3 Copyright 2012 Yahoo! Inc. All rights reserved.
4 Licensed under the BSD License.
5 http://yuilibrary.com/license/
7 YUI.add('loader-rollup', function(Y) {
10 * Optional automatic rollup logic for reducing http connections
11 * when not using a combo service.
17 * Look for rollup packages to determine if all of the modules a
18 * rollup supersedes are required. If so, include the rollup to
19 * help reduce the total number of connections required. Called
20 * by calculate(). This is an optional feature, and requires the
21 * appropriate submodule to function.
26 Y.Loader.prototype._rollup = function() {
27 var i, j, m, s, r = this.required, roll,
28 info = this.moduleInfo, rolled, c, smod;
30 // find and cache rollup modules
31 if (this.dirty || !this.rollups) {
34 if (info.hasOwnProperty(i)) {
35 m = this.getModule(i);
36 // if (m && m.rollup && m.supersedes) {
44 // make as many passes as needed to pick up rollup rollups
48 // go through the rollup candidates
49 for (i in this.rollups) {
50 if (this.rollups.hasOwnProperty(i)) {
51 // there can be only one, unless forced
52 if (!r[i] && ((!this.loaded[i]) || this.forceMap[i])) {
53 m = this.getModule(i);
54 s = m.supersedes || [];
57 // @TODO remove continue
64 // check the threshold
65 for (j = 0; j < s.length; j++) {
68 // if the superseded module is loaded, we can't
69 // load the rollup unless it has been forced.
70 if (this.loaded[s[j]] && !this.forceMap[s[j]]) {
73 // increment the counter if this module is required.
74 // if we are beyond the rollup threshold, we will
75 // use the rollup module
76 } else if (r[s[j]] && m.type == smod.type) {
78 // Y.log("adding to thresh: " + c + ", " + s[j]);
79 roll = (c >= m.rollup);
81 // Y.log("over thresh " + c + ", " + s[j]);
88 // Y.log("adding rollup: " + i);
93 // expand the rollup's dependencies
100 // if we made it here w/o rolling up something, we are done
108 }, '3.5.0' ,{requires:['loader-base']});