Rebuilding Dojo
When you customize your store to use new Dojo widgets that a WebSphere Commerce starter store (for example, Aurora) does not use, or if you remove the use of some Dojo widgets for your store, modify the Dojo build profile and rebuild the Dojo files for optimal client-side performance of your site.
The Dojo files that are deployed with the Aurora starter store are built by using the Dojo Build System. Usually with Dojo, depending on the modules that were used, there are many JavaScript files loaded with the web page. Loading many JavaScript files can have a negative performance impact on bandwidth and load time for your storefront pages. The Dojo Build System combines all the JavaScript files that your application uses into small sets of files to reduce load time and bandwidth.
The Dojo build profile for Aurora starter store can be found in WC_installdir/components/samples/Aurora/dojoprofile/Aurora.profile.js. It is the input to the Dojo Build System. The profile describes the dependencies for each JavaScript that is listed in the dependencies attribute and uses layers to separate Dojo modules into different JavaScript files. For example, a profile might resemble the following code:
dependencies = {
layers: [
{
name: "dojo.js",
dependencies: [ // common for all desktop, tablet and mobile store
"dojo.parser",
"wc.render.Context",
"wc.render.RefreshController",
"wc.service.common",
"wc.widget.RefreshArea"
]
},
{
name: "dojodesktop.js",
layerDependencies: ["dojo.js"],
dependencies: [ // desktop store specific
"dijit._base",
"dijit._base.place",
"dijit._base.popup",
"dijit._base.scroll",
]
},
{
name: "dojotablet.js",
layerDependencies: ["dojo.js"],
dependencies: [ // tablet store specific
"dijit._base",
"dojo.cookie",
"dojox.mobile",
"dojox.mobile.compat",
]
},
{
name: "dojomobile.js",
layerDependencies: ["dojo.js"],
dependencies: [ // mobile store specific
"dijit._base.manager",
"dojox.mobile",
"dojox.mobile.compat",
]
}
],
prefixes: [
[ "dijit", "../dijit" ],
[ "dojox", "../dojox" ],
[ "wc", "../wc" ]
]
}
The
Dojo Build System outputs the following files that are based on the build profile:- dojo.js
- Contains the base Dojo modules that are used across all stores for different platforms (mobile, tablet, and desktop).
- dojodesktop.js
- Contains Dojo modules that are specific for the web store.
- dojomobile.js
- Contains Dojo modules that are specific for the mobile store.
- dojotablet.js
- Contains Dojo modules that are specific for the tablet store.
Before you begin
- Add your custom widgets, or remove unnecessary Dojo widgets files for your store, and modify the Dojo build profile WC_installdir/components/samples/Aurora/dojoprofile/Aurora.profile.js to prepare to rebuild.
Procedure
-
Rebuild Dojo:
- Copy the content from WC_eardir/Stores.war/dojo18_temp/release/dojo/ into WC_eardir/Stores.war/dojo18 so that the directory structure matches the original.
-
Test your changes by going to a page on the storefront.
- Ensure that the number of JavaScript files that are loaded is expected. Note: Some Dojo modules cannot be built into the dojo.js file, like the acme.js and nls files.
- Ensure that all functions work as expected.
- Ensure that the number of JavaScript files that are loaded is expected.