Feature Pack 8

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 that are 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 the WC_installdir/components/store-enhancements/samples/Aurora/dojoprofile/Aurora.profile.js file. 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

Ensure that you completed the following tasks:
  • Add your custom widgets, or remove unnecessary Dojo widgets files for your store, and modify the Dojo build profile WC_installdir/components/store-enhancements/samples/Aurora/dojoprofile/Aurora.profile.js to prepare to rebuild.
  • Update your Java SDK to the latest version.
Windows

Procedure

  1. Rebuild Dojo:
    1. Go to the WC_eardir/Stores.war/ directory.
    2. Rename the current Dojo directory to serve as a backup.
      For example
      • The default Dojo directory is dojo18. If you are using the default Dojo version 1.8, then rename dojo18 to dojo18_backup.
      • If you installed and enabled JR55526, then rename the dojo110 directory to dojo110_backup.
      The rest of this document uses Dojo_backup to refer to the Dojo back up directory that you created.
    3. Create a replacement empty Dojo directory.
      • If you are using the default Dojo version 1.8, then create an empty directory named dojo18.
      • If you installed and enabled JR55526, then create an empty directory named dojo110.
    4. Create a temporary directory.
      For example, dojo18_temp or dojo110_temp. The rest of this document uses Dojo_temp to refer to the temporary directory that you created.
    5. Download and extract the source code of the Dojo version that you want to use.
    6. Copy the contents of the Dojo_backup/WC directory into the Dojo_temp directory.
    7. Copy the util directory from the latest Dojo source into your Dojo_temp directory.
    8. Go to the WC_installdir/components/store-enhancements/samples/Aurora/dojoprofile/ directory.
    9. Copy the Aurora.profile.js file into the WC_eardir/Stores.war/Dojo_temp/util/buildscripts/profile directory.
    10. Open a command line utility.
    11. Go to WC_eardir/Stores.war/Dojo_temp/util/buildscripts and run the following command:

      build -p Aurora --release

      The build runs and a release directory is created in the Dojo_temp directory. Ensure that no errors exist in the results. Review warning messages for any possible issues.

  2. Copy the content from WC_eardir/Stores.war/Dojo_temp/release/dojo/ into the empty Dojo directory so that the directory structure matches the original.
    For example,
    • If you are using the default Dojo version 1.8, then copy the content to WC_eardir/Stores.war/dojo18.
    • If you installed and enabled JR55526, then copy the content to WC_eardir/Stores.war/dojo110.
  3. 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.