Skip to Content | Skip to Navigation


Dojo Overview

The dojo package is the foundation package of the Dojo Toolkit. It consists of three main areas:

  • dojo.js - the bootstrap
  • dojo/_base - basic functionality historically pulled in as part of dojo.js, and historically existing directly under the dojo namespace
  • Dojo Core - more advanced functionality, with some of the functionality available in sub-packages (e.g. dojo/dnd and dojo/store)

Each of these areas are detailed in the following sections.

dojo.js

This file provides the bootstrap for loading other modules, in particular the require() function, previously known as dojo.require(). See the loader documentation for further details of how modules are loaded.

For backwards-compatibility, when dojo.js is included without the async: true configuration flag, all the modules in dojo/_base are implicitly loaded.

dojo/_base

The dojo/_base directory contains modules with basic functionality, such as array operations. Typically, if a function or class exists within the dojo namespace directly (e.g. dojo.forEach()) then it is defined in dojo/_base.

However, note that the modules in dojo/_base are being phased out in favor of top level modules in the dojo/ directory. The dojo/_base files will be maintained until the 2.0 release. See details below for replacement modules.

  • dojo/_base - Overview of all the dojo/_base modules.

Configuring Dojo (dojo/_base/config)

  • dojoConfig (dojo/_base/config)

    Possibility to override certain global settings that control how the framework operates

Array Utilities (dojo/_base/array)

Details on dojo.every, dojo.filter, dojo.forEach, dojo.indexOf, dojo.lastIndexOf, dojo.map, and dojo.some. See the Array QuickStart for an overview.

  • dojo/_base/array

    STUB Overview of the array module

  • dojo.forEach

    Invokes a callback function for every item in array

  • dojo.map

    Applies a callback to each element of arr and returns an Array with the results

  • dojo.some

    Iterate over an array, escaping when the callback returns true for some logic check.

  • dojo.every

    Iterate over an array, escaping when the callback returns false for some logic check.

  • dojo.filter

    Iterate over an array, reducing the array based on the callback return.

  • dojo.indexOf

    Find the index of some element in an Array.

  • NodeList array methods

    • NodeList.indexOf, NodeList.lastIndexOf, NodeList.forEach, NodeList.every, NodeList.some, NodeList.concat, NodeList.map, NodeList.filter, NodeList.at

Language Utilities (dojo/_base/lang)

  • dojo.hitch

    Function that generates a wrapper function that ensures a function that will only ever execute in a defined scope.

  • dojo.partial

    Function that generates a wrapper function that ensures a function will only ever execute globally.

  • dojo.clone

    Clones objects (including DOM nodes) and all children.

  • dojo.delegate

    Returns a new object which “looks” to obj for properties which it does not have a value for.

  • dojo.isString

    Checks if the parameter is a String

  • dojo.isArray

    Checks if the parameter is an Array

  • dojo.isFunction

    Checks if the parameter is a Function

  • dojo.isObject

    Checks if the parameter is an Object

  • dojo.isArrayLike

    Checks if the parameter is like an Array

  • dojo.isAlien

    Checks if the parameter is a built-in function

  • dojo.trim

    Trim whitespace from a String

  • dojo.replace

    Simple templates with parameterized substitutions.

  • dojo.mixin

    Mixes one object into another. Can be used as a shallow copy

  • dojo.extend

  • dojo.getObject

    Get a property from a dot-separated string, such as “A.B.C”

  • dojo.setObject

    Set a property from a dot-separated string, such as “A.B.C”

  • dojo.exists

    Determine if an object supports a given method

HTML Utilities (dojo/_base/html)

The dojo/_base/html module contains basic DOM & HTML handling functions for backward compatibility purposes.

New code should use the dojo/dom* modules (see “Dojo core” section below for details).

Deferred Utilities (dojo/_base/Deferred)

  • dojo/_base/Deferred

    Communication between asynchronous calls

    • dojo.when

      Allows a single code path for synchronous and asynchronous code execution.

Kernel (dojo/_base/kernel)

  • dojo/_base/kernel

    STUB from 1.7+ dojo/_base/kernel module contains the following parts of Dojo API:

Window (dojo/_base/window)

from 1.7 + dojo/_base/window module collects following part of dojo APIs

  • dojo.doc

    Alias for the current document.

  • dojo.body

    Return the body element of the document

  • dojo.setContext

    Changes the behavior of many core Dojo functions that deal with namespace and DOM lookup

  • dojo.withGlobal

    Call callback with globalObject as dojo.global and globalObject.document as dojo.doc

  • dojo.withDoc

    Call callback with documentObject as dojo.doc

Effects (dojo/_base/fx)

Connect (dojo/_base/connect)

This module provides event handling for DOM nodes, and AOP for functions. However, it is superseded by the dojo/on, dojo/aspect, and dojo/topic modules, which should be used for new code.

The methods defined in this module are:

NodeList (dojo/_base/NodeList)

  • NodeList.connect

    Connects events to every node in the list, like dojo.connect

  • NodeList.events

    Common event names mapped as functions on a NodeList - eg: .onclick(function(){})

Event (dojo/_base/event)

The dojo/_base/event module defines dojo DOM event API. See the dojo/_base/connect section above.

Document Lifecycle - Unload (dojo/_base/unload)

AJAX/XHR (dojo/_base/xhr)

Package System (dojo/_base/loader)

This module is defining deprecated symbols for loading. See the loader documentation for details on new replacement API’s.

JSON Tools (dojo/_base/json)

  • dojo.fromJson

    Parses a JSON string to return a JavaScript object

  • dojo.toJson

    Returns a JSON serialization of an object

Objects / OO Utilities (dojo/_base/declare)

Colors (dojo/_base/Color)

  • dojo._base.Color

    Color object and utility functions to handle colors. Defines the following API functions:

    • dojo.colorFromArray
    • dojo.colorFromHex
    • dojo.colorFromString
    • dojo.colorFromRgb

Miscellaneous Base

  • dojo/browser

    This module causes the browser-only base modules to be loaded.

  • dojo.global

    Alias for the global scope

  • dojo.keys

    A collection of key constants.

  • dojo._Url

    dojo._Url is used to manage the url object.

  • dojo/_base/sniff

  • dojo/sniff STUB

    dojo/_base/sniff is introduced in dojo 1.7 as the browser detection utility.

Dojo Core

While using the legacy API, many of the modules listed here are auto-loaded and made available in the global scope for Legacy compatibility purposes, it is not advisable. The best practice is to require in only the modules you need to use within your application. For example, previously, if you need to retrieve a DOM node by its ID, you might have accomplished this by just accessing the dojo global scope object like:

var myNode = dojo.byId("myNode");

But to ensure the current best practices from Dojo 1.7 onwards, you should do the following:

require("dojo/dom", function(dom){
  var myNode = dom.byId("myNode");
});

DOM (dojo/dom*)

The following modules define the core DOM API for the Dojo Toolkit. For compatibility purposes, aliases to the Legacy API are defined in dojo/_base/html and dojo/_base/xhr modules. For new development it is recommended to require only the individual modules of the parts of the API that are needed and to reference them via their return variable. See each module for examples of what the common conventions are for doing this.

  • DOM Core (dojo/dom)

    This module defines the core dojo DOM API. The convention for the return variable for this module is dom.

    • dojo.byId

      Select a DOM node by ‘id’.

    • dojo.isDescendant

    • dojo.setSelectable

  • Manipulation (dojo/dom-construct)

    This module defines the core dojo DOM construction API. The convention for the return variable for this module is domConstruct.

  • Attributes (dojo/dom-attr)

    This module defines the core Dojo DOM attributes API. This module will be retired in the future and superseded by dojo/dom-prop. The convention for the return variable for this module is domAttr.

    • dojo.attr

      Modifying DOM node attributes

    • dojo.getAttr

      Gets an attribute on an HTML element.

    • dojo.setAttr

      Sets an attribute on an HTML element.

    • dojo.hasAttr

      Returns true if the requested attribute is specified on the given element, and false otherwise.

    • dojo.removeAttr

      Removes an attribute from an HTML element.

    • dojo.getNodeProp

      Returns an effective value of a property or an attribute.

  • Form (dojo/dom-form)

    This module defines form-processing functions. The convention for the return variable for this module is domForm.

  • Styles (dojo/dom-style)

    This module defines the core dojo DOM style API. The convention for the return variable for this module is domStyle.

  • Class (dojo/dom-class)

    This module defines the core Dojo DOM class API. The convention for the return variable for this module is domClass.

    • dojo.hasClass

      Returns a boolean depending on whether or not a node has a passed class string.

    • dojo.addClass

      Adds a CSS class to a node.

    • dojo.removeClass

      Removes a class from a Node.

    • dojo.toggleClass

      Toggles a className (or now in 1.4 an array of classNames).

    • dojo.replaceClass

      Replaces one or more classes on a node if not present. Operates more quickly than calling dojo.removeClass and dojo.addClass.

  • Geometry (dojo/dom-geometry)

    This module defines the core dojo DOM geometry API. The convention for the return variable for this module is domGeom.

    • dojo.coords

      Getter for the coordinates (relative to parent and absolute) of a DOM node. Deprecated in Dojo 1.4.

    • dojo.position

      Getter for the border-box x/y coordinates and size of a DOM node.

    • dojo.marginBox

      Getter/setter for the margin-box of node

    • dojo.contentBox

      Getter/setter for the content-box of node

    • dojo.getMarginBox

      Get an object that encodes the width, height, left and top positions of the node’s margin box.

    • dojo.setMarginBox

      Sets the size of the node’s margin box and placement (left/top), irrespective of box model.

    • dojo.getContentBox

      Get an object that encodes the width, height, left and top positions of the node’s content box, irrespective of the current box model.

    • dojo.setContentSize

      Sets the size of the node’s contents, irrespective of margins, padding, or borders.

  • Property (dojo/dom-prop)

    This module defines the core dojo DOM properties API. The convention for the return variable for this module is domProp.

IO-Query (dojo/io-query)

  • dojo.objectToQuery

    Takes a name/value mapping object and returns a string representing a URL-encoded version of that object.

  • dojo.queryToObject

    Create an object representing a de-serialized query section of a URL. Query keys with multiple values are returned in an array.

Robot (dojo/robot - dojo/robotx)

  • dojo/robot

    Users who use doh+dojo get the added convenience of dojo.mouseMoveAt instead of computing the absolute coordinates of their elements themselves.

  • dojo/robotx

Loads an external app into an iframe and points dojo.doc to the iframe document, allowing the robot to control it

Document Lifecycle - Onload (dojo/ready)

  • dojo.ready

    Call functions after the DOM has finished loading and widgets declared in markup have been instantiated. When using AMD, in most situations the loader plugin dojo/domReady is preferable.

AJAX I/O transports (dojo/io/*)

AJAX RPC transports (dojo/rpc/*)

Query (dojo/query)

  • dojo.query

    The swiss army knife of DOM node manipulation in Dojo.

Selectors (dojo/selector/*)

The different selector engines that are available in Dojo.

  • dojo/selector/_loader STUB

    This module handles loading the appropriate selector engine for the given browser

  • dojo/selector/acme STUB

    This is the default selector engine for Dojo.

  • dojo/selector/lite STUB

    A small lightweight query selector engine that implements CSS2.1 selectors minus pseudo-classes and the sibling combinator, plus CSS3 attribute selectors.

NodeList (dojo/NodeList-*)

Various modules that wrap DOM nodes and provide enhanced functionality and management.

Browser History (dojo/back - dojo/hash)

  • dojo.back (dojo/back)

    Browser history management resources (Back button functionality)

  • dojo.hash (dojo/hash)

    Normalized onhashchange module

Store (dojo/store)

Cache (dojo/cache)

  • dojo.cache

    A mechanism to cache inline text. This has been deprecated in 1.7 in lieu of the dojo/text AMD loader plugin.

Date (dojo/date)

Drag and Drop (dojo/dnd)

AMD Loader Plugins

There are several modules that are plugins for the AMD Loader system. Consult the Loader documentation for more information on AMD Loader Plugins.

  • dojo/domReady

    Defers execution of the module’s factory function until the DOM is ready.

  • dojo/text

    Loads text resources; it is a superset of RequireJS’s text plugin, and subsumes dojo.cache.

  • dojo/i18n

    Loads i18n bundles either in legacy or AMD format. It includes the legacy i18n API and is a superset of RequireJS’s i18n plugin.

  • dojo/has

    Allows has.js expressions to be used to conditionally load modules.

  • dojo/load

    A convenience plugin for loading dependencies computed at runtime.

  • dojo/require

    Downloads a legacy module without loading it. This allows the legacy code path to be guaranteed.

  • dojo/loadInit

    Causes dojo.loadInit callbacks then other legacy API functions to be executed–in particular those that are associated with a module.

Miscellaneous Core

  • dojo.AdapterRegistry

    A registry to make contextual calling/searching easier

  • dojo.behavior

    Utility for unobtrusive/progressive event binding, DOM traversal, and manipulation

  • dojo.Stateful

    Get and set named properties in conjunction with the ability to monitor these properties for changes

  • dojo.aspect

    Provides aspect oriented programming facilities to attach additional functionality to existing methods

  • dojo.cldr

    A Common Locale Data Repository (CLDR) implementation

  • dojo.colors

    CSS color manipulation functions

  • dojo.cookie

    Simple HTTP cookie manipulation

  • dojo.currency

    Localized formatting and parsing routines for currency data

  • dojo.DeferredList

    Event handling for a group of Deferred objects

  • dojo.fx

    Effects library on top of Base animations

  • dojo.gears

    Google Gears

  • dojo.html

    Inserting contents in HTML nodes

  • dojo.i18n

    Utility classes to enable loading of resources for internationalization

  • dojo.number

    Localized formatting and parsing methods for number data

  • dojo.parser

    The DOM/Widget parsing package

  • dojo.regexp

    Regular expressions and Builder resources

  • dojo.string

    String utilities for Dojo

  • dojo.mouse

    Provides extension events for hovering and mouse button utility functions

  • dojo/on

    Provides normalized event listening and event dispatching functionality

  • dojo/touch

    Provides standardized touch events

  • dojo.require

    Loads a Dojo module, by name

See also

  • Dijit

    The widget system layered on top of Dojo

  • DojoX

    An area for development of extensions to the Dojo toolkit