What's in This Book

Part I of this book is very much a standard library reference that exposes you to the various nooks and crannies of Base and Core, the parts of the toolkit that comprise a JavaScript standard library. Base comes across the wire[5] at less than 30KB, and is feverishly optimized for speed, size, and utility. Packing rich functionality as diverse as AJAX calls, DOM querying based on CSS selector syntax, standardized event propagation, and functional programming utilities like map and filter, you'll quickly wonder how you ever got by without it. Core includes lots of additional features for operations like animations and drag-and-drop; while they are incredibly useful, they just aren't as common to all use cases as the machinery in Base.

Tip

One caveat about Part I of this book is that it defers a full-blown discussion of the parser until Chapter 11, when Dijit is introduced, because the most common use case of the parser is for parsing widgets. The parser is briefly mentioned in a Chapter 7 sidebar, though, because it is quite helpful for conveniently setting up drag-and-drop.

Part I includes the following chapters:

Chapter 1

Provides a quick introduction to the toolkit including topics such as Dojo's architecture, how to get and install Dojo, how to get Dojo into a web page, and some sections that provide some examples so that you can see Dojo in action.

Chapter 2

Provides an extensive overview of commonly used utility functions that are extremely common and useful for any web application. Most of these functions are designed to smooth out browser incompatibilities, plug holes where JavaScript or DOM implementations came up a bit short, and otherwise reduce the boilerplate you have to write to get some work done.

Chapter 3

Introduces constructs for managing communication within the page. The two primary paradigms discussed involve directly attaching to a specific event that happens, whether in the DOM, on an Object, or a standalone function and the publish/subscribe idiom that involves broadcasting a topic and allowing any arbitrary subscriber to receive and respond as needed.

Chapter 4

Provides a quick overview of AJAX and the toolkit's machinery for communicating with the server via the XMLHttpRequest Object. Deferreds are also discussed, which provide a uniform layer for handling asynchronous events; you might think of Deferreds as almost providing the illusion of having a thread available even though you cannot program threads in JavaScript. Other core facilities such as cross-domain JSON, Remote Procedure Calls, and IFRAME transports are discussed.

Chapter 5

Introduces the toolkit's mechanism for universally querying the DOM using CSS selector syntax, processing the lists of nodes that are returned using convenient built-in functions that allow arbitrary events chains to be built up, and an idiom for separating the behavior of DOM nodes from specific actions defined in HTML markup.

Chapter 6

Provides a quick overview and examples for internationalizing a web application using the toolkit's utilities; also includes an overview of the various constructs that are available for manipulating inherently international concepts such as dates, time, currency, and number formatting.

Chapter 7

Includes a fairly standalone tutorial on how Dojo makes adding drag-and-drop to an application a breeze.

Chapter 8

Provides a fairly standalone tutorial on Dojo's built-in machinery for animating arbitrary CSS properties via a variety of effects such as wipes, slides, and fades. Utilities for blending and manipulating colors are also included.

Chapter 9

Provides a discussion of Dojo's data abstraction infrastructure, which provides a mediating layer between application logic and specific backend data formats, whether they be an open standard or a closed proprietary source.

Chapter 10

Ramps up for Part II on Dijit by introducing machinery for mimicking class-based object-oriented programming with Dojo, which Dijit uses fairly extensively.

Part II systematically explores the rest of the toolkit, including complete coverage of Dijit, the rich layer of drop-in replacements for all of those customized HTML controls that have been written (and rewritten) so many times. Dijit is designed so that it can be used in the markup with little to no programming required, and you'll find that it's possible to build fantastic-looking web pages with a fraction of the effort since they already look and behave much like user interface controls from desktop applications.

Part II concludes with a discussion of the build system and unit testing framework provided by Util. The build system includes a highly configurable entry point to ShinkSafe, a tool that leverages the Rhino JavaScript engine to compress your code—often by a third or more. DOH stands for the Dojo Objective Harness (and is a pun on Homer Simpson's famous "D'oh!" expletive) and provides a standalone system for unit testing your JavaScript code.

Part II includes the following chapters:

Chapter 11

Introduces Dijit, discusses various issues such as design philosophy, accessibility, the parser (technically a Core facility, but with the most common use case of parsing a page that contains dijits), and patterns for using dijits. The chapter ends with an overview of each major Dijit subproject.

Chapter 12

Digs deep into how a dijit is laid out on disk as well as how its lifecycle works once it's been instantiated and in memory. Provides a number of short examples that accentuate the finer points of the lifecycle. Understanding the dijit lifecycle is essential for the chapters that follow.

Chapter 13

Provides a quick review of normal HTML forms and then jumps right into a thorough survey of the form widgets, which are by far the most inheritance-intensive collection available. The form widgets are drop-in replacements for all of the common form elements that are used in virtually any web design; assortments of commonly used buttons, specialized text boxes, and sliders are a few of the topics covered. Additional derived elements such as drop-down combo boxes that have been implemented and reimplemented far too many times by now are also included.

Chapter 14

Introduces the layout widgets, a collection of widgets that provide the skeleton for complex layouts that often involves tricky and tedious CSS, swapping in and out tiles that go from being hidden to visible based on the application's state, tabbed layouts, and more.

Chapter 15

Covers the remaining widgets in the toolkit, which loosely correspond to common application controls such as tooltips, modal dialogs, menus, trees, and rich text editors.

Chapter 16

Wraps up the book with some of the most commonly overlooked yet important topics for deploying an application; includes an extensive discussion of the build tools that trivialize the effort entailed in compressing, minifying, and consolidating JavaScript to minimize file size and HTTP latency incurred, a unit testing framework, and other production considerations that help to give your app that last bit of pizzazz.

There are two supplemental appendixes to the book: a concise survey of DojoX, a collection of specialized and experimental extensions, and a Firebug tutorial. While DojoX is an absolute treasure chest of widgets and modules for anything from charting to cryptography to the much acclaimed and highly flexible grid widget, there are fewer guarantees about stability or API consistency for DojoX subprojects than there are for Base, Core, and Dijit; thorough coverage on DojoX could easily span multiple volumes of its own.

The other appendix provides a handy Firebug tutorial that gets you up to speed with all of its great features that will save you time when it becomes necessary to debug or quickly explore new ideas through its command line style interface. If you haven't heard of Firebug, it's a fantastic Firefox add-on that allows you to literally deconstruct every facet of a page—anything from inspecting and manipulating style of DOM nodes to monitoring the network activity to using a command-line interface for executing JavaScript.



[5] As we'll be discussing more in subsequent chapters, "across the wire" refers to the size of content after it has been gzipped, because that's normally the way web servers transfer web pages to clients.

Get Dojo: The Definitive Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.