Skip to Content | Skip to Navigation


Expanding dojo.provide calls

Status:Draft
Version:1.0
Available:since V1.3

Expands dojo.provide calls with faster calls at the expense of a larger file size in built layers.

Introduction

The Dojo Build provides a mechanism for expanding dojo.provide calls within your code into faster javascript equivalents, avoiding expensive lookups through dojo.getObject when it is otherwise safe to assume. This is a simple toggle on a build command line or profile called “expandProvide”, and defaults to ‘false’.

Usage

Only use the option if your profiling reveals that dojo.provide calls are taking a noticeable amount of time. It replaces dojo.provide(“foo.bar”) statements with the shortest valid programmatic equivalent:

1
if(typeof foo=="undefined"){foo={};};foo.bar=foo.bar||{};

Simply pass the parameter as a command line argument:

sugr:~/dojo/util/buildscripts $ ./build.sh action=release expandProvide=true version=1.3.0 profile=standard

Or mix the option into your profile:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
      dependencies = {
              // expand dojo.provide calls
              expandProvide: true,

              // rest of profile:
              layers: [{ /* ... */ }],
              prefixes: [
                      [ "dijit", "../dijit" ],
                      [ "dojox", "../dojox" ]
              ]
      }