Authors:Jared Jurkiewicz, Yoshiroh Kamiyama
Developers:Yoshiroh Kamiyama, Jared Jurkiewicz
Available:since V1.5

Have you wanted to build applications for the iPhone, Android, or other similar WebKit based mobile browsers that had the look and feel of a ‘native’ application for the device, but was merely a web-page so you retained total control? If so, then this module may provide much of what you need. This project provides through CSS3 and custom styles, interfaces that display and work well on mobile devices.

The code is deliberately kept as lightweight as possible, using CSS3 animations and the like to perform the effects. There is a compat.js, which will simulate most of the effects using dojo.fx where possible on browsers such as FireFox and IE. It will not load by default, it has to be required in separately.

Note that use of dijit._Container, dijit._Contained, dijit._Templated, and dojo.query is intentionally avoided to reduce download code size.


  • Extemely lightweight parser for instantiating widgets to keep code size down. It does not support embedded script behaviors or the like.
  • Transitional effects such as flip, slide and fade to move between views.
  • CSS3 Animations where possible. This provides high-speed, smooth, animations on WebKit based browsers. For non-webkit based browsers, a ‘compat’ module exists to mimic most of the animations by using dojo.animateProperty.
  • CSS themes for Apple’s iPhone and Google Android based mobile phones to mimic look and feel.
  • A series of lightweight widgets to mimic basic mobile device native interfaces, including:
    • View- A single ‘view’
    • ScrollableView- A view with touch scroll
    • FlippableView- A view that can be swiped horizontally
    • Switch - An on/off toggle-style button.
    • Button - Styled to match the device.
    • Heading - Styled to match the device
    • Round-corner-rectangle-boxes.
    • Edge-To-Edge category
    • Edge to Edge List - A basic list of items with equal width.
    • Round Corner - List of rounded-corner rectangles for data display.
    • ListItem - Basic list items to use in the various list containers.
    • IconContainer - A container to house icons for actions/events.
    • IconItem - A idget for representing an icon and associated actions.
    • Tab Container - A basic native-looking tab container.
    • TabPane - A basic container for tab content (used in conjunction with Tab Container)
    • ProgressIndicator - A native-looking progress bar/display page.


dojo.i18n is NOT used for because:

  • Use of it increases the code size, which affects cachability of the content.
  • Not good for client-side runtime performance, which is important for mobile devices. The lookup time matters to lighter devices such as a phone. It has the added advantage of extending battery life due to avoiding CPU cycles for string manipulations.

Recommended approach is to substitute localized strings on the server due to the following reasons:

  • Server-side markup generation is the typical usage of
  • Should be able to use server-side i18n facility (e.g. Java resource bundle)
  • No http requests to retrieve i18n resources are necessary
  • Client-side does not need to look up the i18n resource table

Cross-Browser Compatibility supports not only webkit-based mobile browsers, but also non-CSS3 desktop browsers such as IE and (older) Firefox. The CSS3 compatibility module ( is provided to support non-CSS3 browsers. By default compatibility is not loaded, so if you require your application to work on older browsers (or desktop browsers), you need to conditionally import the package as part of its initialization. See the example below:

dojo.requireIf(!dojo.isWebKit, "");

If is loaded, it directly replaces some of the methods of the widgets to use emulation techniques for the normally CSS3 based animations. This way, your applications do not need to be changed, and thus html pages remains the same regardless of whether this compatibility module is used or not. simply uses traditional techniques. For example, images are used for buttons, gradient colors, rounded corners, etc. For transition animations, dojo.fx is used.

Note: automatically loads the compatibility CSS files. It searches the current page for <link> elements or @import directives in a <style> element, and tries to load corresponding -compat.css files. For example, if it finds .../themes/iphone/iphone.css, it loads .../themes/iphone/iphone-compat.css. (Note: in dojo-1.5 searches only for <link> elements, but the one in dojo-1.6 searches for @import as well.)

Build was designed to have as few dependencies on the dojo and dijit base modules as possible in order to reduce the total download code size for better start-up time performance. For example, use of dijit._Container, dijit._Contained, dijit._Templated, and dojo.query is intentionally avoided even where they are normally used. However, by default, all the dojo base modules and the dijit base modules are baked into the built file (dojo.js) by the dojo build tool regardless of whether they are actually used or not. So, to take advantage of's minimum-dependency approach, you need to specify appropriate build options and dependency information when you build your application. There are sample build profile files and batch files available for that purpose in the dojox/mobile/build/ directory.

Before running the build batch file, you may need to manually apply the following patch to your build script in order to completely remove all the unused modules from your build. (As you can see, it is just addition of "false&&" in the while condition.) The patch disables finding the dojo base modules being used from the dependent modules with a simple pattern matching, which sometimes unexpectedly picks up unused modules. The file to be patched is util/buildscripts/jslib/buildUtil.js.

--- buildUtil.js-orig
+++ buildUtil.js
@@ -1506,7 +1506,7 @@
   var addedResources = {};
-  while((matches = buildUtil.baseMappingRegExp.exec(tempContents))){
+  while(false&&(matches = buildUtil.baseMappingRegExp.exec(tempContents))){
       var baseResource = buildUtil.baseMappings[matches[1]];
       //Make sure we do not add the dependency to its source resource.

From the command line, you can run the batch file. Use "build.bat" for Windows, or "" for Linux. Simple usage is as follows.

> build
Usage: build separate|single [webkit]
  separate  Create mobile.js that includes only
  single    Create a single dojo.js layer that includes
  webkit    Enable webkitMobile=true option (Loses PC browser support)
Create mobile.js that includes only the modules. It does not include the dojo base or the dijit base modules. Compat.js is also created for desktop browser support.
Create a single dojo.js layer that includes and all the required modules. Compat.js is also created for desktop browser support.
Enable the webkitMobile=true build option, which strips out many code chunks that are not necessary for webkit-based mobile browsers. For example, IE or Firefox specific code is excluded from the build. This reduces the total code size, but the built module will not work on desktop browsers even with the compatibility module (compat.js).


Loading the basic codebase is extremely simple. It's a couple requires and then selecting the CSS. That's it.

Loading the javascript:

// Load the basic mobile widgetry and support code.

// Load the lightweight parser.  dojo.parser can also be used, but it requires much more code to be loaded.

// Load the compat layer if the incoming browser isn't webkit based
dojo.requireIf(!dojo.isWebKit, "");

Selecting the CSS to apply (iphone or android currently) is equally simple:

<link rel="stylesheet" type="text/css" href="dojox/mobile/themes/iphone/iphone.css"></link>


Basic example, view to view swapping:

  // Load the basic mobile widgetry and support code.

  // Load the lightweight parser.  dojo.parser can also be used, but it requires much more code to be loaded.

  // Load the compat layer if the incoming browser isn't webkit based
  dojo.requireIf(!dojo.isWebKit, "");
<link href="{{baseUrl}}dojox/mobile/themes/iphone/iphone.css" rel="stylesheet"></link>
<div id="main" dojoType="" selected="true">
  <h1 dojoType="">Settings</h1>
  <ul dojoType="">
    <li dojoType="" icon="{{baseUrl}}dojox/mobile/tests/images/i-icon-1.png">
      Coolness Mode
      <div class="mblItemSwitch" dojoType=""></div>
    <li dojoType="" icon="{{baseUrl}}dojox/mobile/tests/images/i-icon-2.png" rightText="mac" moveTo="disco">
      Disco Room
    <li dojoType="" icon="{{baseUrl}}dojox/mobile/tests/images/i-icon-3.png" rightText="AcmePhone" moveTo="disco">

<div id="disco" dojoType="">
  <h1 dojoType="">Hello</h1>
  <ul dojoType="">
    <ul dojoType="">
    <li dojoType="" moveTo="main">
      I'm a square, man.
    <li dojoType="" moveTo="main">
      Leave Disco Room
Error in the documentation? Can’t find what you are looking for? Let us know!