Select to view content in your preferred language

Why are so many dojo modules pulled in?

2130
16
11-15-2011 11:08 AM
RexBradford
Emerging Contributor
I'm wondering if it's possible to reduce the number of unused and unwanted dojo modules being pulled in, to help reduce app load time.

I am explicitly requiring only these 11 modules:

dojo.require("esri.map");
dojo.require("esri.layers.osm");
dojo.require("esri.virtualearth.VEGeocoder");
dojo.require("esri.layers.FeatureLayer");
dojo.require("esri.layers.KMLLayer");
dojo.require("esri.dijit.Scalebar");
dojo.require("esri.toolbars.navigation");
dojo.require("dijit.layout.BorderContainer");
dojo.require("dijit.layout.ContentPane");
dojo.require("dijit.Dialog");
dojo.require("dojox.collections.Dictionary");

so these entries in Firebug's net window are hardly surprising, except maybe the first:

firebug.xd.js
svg.xd.js
jsapi_en-us.xd.js
osm.xd.js
KMLLayer.xd.js
FeatureLayer.xd.js
Scalebar.xd.js
BorderContainer.xd.js
Dialog.xd.js
ContentPane.xd.js
Dictionary.xd.js.

but then look at what keeps coming after those (.xd.js file extensions removed to save room):

iframe, MapImageLayer, Popup, _LayoutWidget, cookie, _ContentPanelResizeMixin, html, loading, TimedMoveable, _FormMixin, DialogUnderlay, _DialogMixin, common, TooltipDialog, PopupBase, Chart2D, base, Tooltip, _Contained, Default, Default (twice!), Invisible, Lines, Areas, MarkersOnly, Markers, Scatter, StackedAreas, StackedLines, Columns, StackedColumns, Bars, ClusteredColumns, StackedBars, ClusteredBars, Pie, Grid, Bubble, Candlesticks, Spider, OHLC, Chart Theme, Tooltip, Base, functional, fold, scan, linear, colors, common, utils, Base, common, Base, reversed, fx, gradutils, sequence, Element, _PlotEvents, primitive, easing, Series, color, Palette, object, lambda, array, common, _base.

There are over 70 in all.  A few dozen seem to be related to charting, which is ironic given:

1. I am using google charts for all charting, and don't try to include any dojo chart tools at all
2. On startup my app prints out two warnings from inside dojo somewhere:
EXPERIMENTAL: dojox.charting.plot2d.Spider -- APIs subject to change without notice.
DEPRECATED: dojox.charting.Chart2D Use dojo.charting.Chart instead and require all other components explicitly -- will be removed in version: 2.0

Does anybody know how to get dojo under control?  I thought the whole idea of Dojo was that it would only bring in stuff that's needed?

Rex Bradford
Direct Relief International
0 Kudos
16 Replies
derekswingley1
Deactivated User
Thanks.  Are the modules only pulled in by OSM when the layer is used though?  If I add dojo.require("esri.layers.osm"); to my code, I don't get all those charting modules.  With KML, just requiring seems to be all it takes to pull in the modules.

Rex Bradford
Direct Relief International


OSM doesn't require the charting modules, KMLLayer does. When you dojo.require KMLLayer, the charting modules are loaded. Not that it really matters, but the actual dependency is KMLLayer requires esri.dijit.Popup and popup requires the charting modules.
0 Kudos
RexBradford
Emerging Contributor
OSM doesn't require the charting modules, KMLLayer does. When you dojo.require KMLLayer, the charting modules are loaded. Not that it really matters, but the actual dependency is KMLLayer requires esri.dijit.Popup and popup requires the charting modules.


Thanks again, this information helps a lot.  Still, not to be cheeky, but I think having esri.digit.Popup automatically pull in a couple dozen charting modules is a "performance bug".

Rex Bradford
Direct Relief International
0 Kudos
MarkHoover
Frequent Contributor
One assumes the Popup dijit requires those modules to function properly, otherwise they wouldn't be brought in.
0 Kudos
derekswingley1
Deactivated User
...I think having esri.digit.Popup automatically pull in a couple dozen charting modules is a "performance bug".


It's by design. The popup can do many different things. All the additional functionality requires more resources/modules.
0 Kudos
RexBradford
Emerging Contributor
It's by design. The popup can do many different things. All the additional functionality requires more resources/modules.


I get it.  Still, is there not a way to pull charts in only when you actually want to use charts in a popup?  I guess I don't understand dojo well enough - it seems like a benefit of having a system which can pull in modules on demand would be the ability to avoid this very problem.
0 Kudos
JeffPace
MVP Alum
I get it.  Still, is there not a way to pull charts in only when you actually want to use charts in a popup?  I guess I don't understand dojo well enough - it seems like a benefit of having a system which can pull in modules on demand would be the ability to avoid this very problem.


sure, you could write you open popup, and conditionally load the requires based on whether or not a chart is included. 

Since the esri api preps for charts in the popup, it HAS to preload the module.
0 Kudos
MattLane
Frequent Contributor
It's by design. The popup can do many different things. All the additional functionality requires more resources/modules.


Hate to open back up this discussion, but I'd like to discuss it regarding PopupMobile. Since PopupMobile is meant to be used on a mobile accessed site, I would think minimizing size and # of requests would be important. Yeah, I could hack up and host my own PopupMobile to remove unnecessary stuff (like charting in my case), which I'll have to do again if I want to switch to 2.9 when it comes out.

My testing with only v2.8compact and claro.css links:

dojo.require("esri.map") only - 6 requests and 168KB total
dojo.require("esri.map") AND dojo.require("esri.dijit.PopupMobile") - 94 requests and 433.5KB total
0 Kudos