Dojo Toolkit Explained

Dojo Toolkit (before version 2), Dojo (since version 2)
Developer:Dojo Foundation
Latest Release Version:7.0.6
Latest Release Date:[1]
Latest Preview Version:8.0.0-beta.7
Latest Preview Date:[2]
Operating System:Cross-platform
Repo:Dojo Toolkit 1.x https://github.com/dojo/dojo
Dojo Framework 2+ https://github.com/dojo/framework
Programming Language:Dojo Tookit 1.x: JavaScript, Dojo >= 2.x: TypeScript[3]
Genre:JavaScript toolkit (or library)
License:The modified BSD license or the Academic Free License (≥ 2.1)[4]
Website:https://dojotoolkit.org, https://dojo.io/

Dojo Toolkit (stylized as dōjō toolkit) is an open-source modular JavaScript library (or more specifically JavaScript toolkit) designed to ease the rapid development of cross-platform, JavaScript/Ajax-based applications and web sites. It was started by Alex Russell, Dylan Schiemann, David Schontzler, and others in 2004[5] and is dual-licensed under the modified BSD license or the Academic Free License (≥ 2.1).[4]

The Dojo Foundation was a non-profit organization created with the goal to promote the adoption of the toolkit. In 2016, the foundation merged with jQuery Foundation to become JS Foundation.[6] [7] [8]

Overview

Dojo is a JavaScript framework targeting the many needs of large-scale client-side web development. For example, Dojo abstracts the differences among diverse browsers to provide APIs that will work on all of them (it can even run on the server under Node.js); it establishes a framework for defining modules of code and managing their interdependencies; it provides build tools for optimizing JavaScript and CSS, generating documentation, and unit testing; it supports internationalization, localization, and accessibility; and it provides a rich suite of commonly needed utility classes and user-interface widgets.

Dojo is completely open source. The toolkit includes about three thousand JavaScript modules, in addition to images and other resources.

The Dojo Toolkit is organized in several parts:

Features

Widgets

Dojo widgets are components — comprising JavaScript code, HTML markup, and CSS style declarations — that provide multi-browser (not to be confused with cross-browser), interactive features:

Asynchronous communication

One important feature of Ajax applications is asynchronous communication of the browser with the server: information is exchanged and the page's presentation is updated without a need for reloading the whole page. Traditionally, this is done with the JavaScript object XMLHttpRequest. Dojo provides an abstracted wrapper (dojo.xhr) around various web browsers' implementations of XMLHttpRequest, and dojo.io also supports other transports (such as hidden IFrames) and a variety of data formats. Using this approach, it is easy to have the data a user enters into a form sent to the server "behind the scenes"; the server can then reply with some JavaScript code that updates the presentation of the page.[9]

Packaging system

Dojo provides a packaging system to facilitate modular development of functionality in individual packages and sub-packages; the base Dojo "bootstrap" script initializes a set of hierarchical package namespaces — "io", "event", etc. — under a root "dojo" namespace. After initialization of the root namespace, any Dojo package can be loaded (via XMLHttpRequest or other similar transport) by using utility functions supplied in the bootstrap. It is also possible to initialize additional namespaces within or parallel to the "dojo" namespace, allowing extensions of Dojo or the development of private Dojo-managed namespaces for third-party libraries and applications.

Dojo packages can consist of multiple files and can specify which files constitute the entire package. Any package or file can also specify a dependency on other packages or files; when the package is loaded, any dependencies it specifies will also be loaded.

Workarounds for cross-domain loading of most Dojo packages are provided (though this requires a specialized build of Dojo).

Dojo also provides a mechanism for building "profiles"; the build system takes as input a list of packages, and uses Rhino to create a single compressed JavaScript file containing those packages and all their dependencies. This allows all necessary code to be loaded and initialized at once, and permits caching of the code (most web browsers do not cache files loaded via XMLHttpRequest). Pre-built profiles for some common use cases are available for download from the same location as the full toolkit.

Client-side data storage

In addition to providing support functions for reading and writing cookies, Dojo formerly supported a local, client-side storage abstraction named Dojo Storage. Dojo Storage allows web applications to store data on the client-side, persistently and securely and with a user's permission. It works across existing web browsers, including Internet Explorer, Firefox, and Safari. When included in a web page, Dojo Storage determines the best method for persistently storing information. Firefox 2 uses native browser persistence; on other browsers, it uses a hidden Flash applet. With Flash 6+ being installed on about 95% of computers connected to the web,[10] this makes the storage mechanism accessible for much of the web's installed base. For a web application loaded from the file system, i.e., from a file:// URL, Dojo Storage will transparently use XPCOM on Firefox and ActiveX on Internet Explorer to persist information. The programmer using Dojo Storage is abstracted from the storage mechanism used and is presented with a simple hash table abstraction, with methods such as put and get.Dojo Storage is not supported in versions later than the 1.3 release.

Server-side data storage

As of January 2007, Dojo includes the following example server-side datastore implementations in the dojo.data namespace:[11]

Support for Adobe Integrated Runtime (AIR)

Dojo can be used in JavaScript-based Adobe AIR applications. It has been modified to meet AIR's security requirements.

SitePen, a Dojo consulting company, has made an Adobe AIR application called "Dojo Toolbox" using Dojo. It includes an API viewer and a GUI to Dojo's build system. Normally, the build system is run from within Rhino, but in this AIR application the build system can be run from AIR, without the use of Java.[12]

Criticisms

Loading

Earlier versions of Dojo had a reputation for being bulky and slow to load.[13] It also required extra work to load Dojo across domains, e.g., from a CDN. Addressing these problems was the major goal of Dojo 1.7, which introduced asynchronous module definition (AMD) and a "nano" loader.[14]

Documentation

Dojo has long been criticized for its incomplete, scattered, and outdated documentation. Recognizing this, the developers made huge improvements in the documentation for the 1.8 release, including new tutorials, an API browser, filling in the missing pieces, and updating most examples to AMD style.[15] [16]

A number of books have been written about Dojo, but all based upon Dojo 1.3 or earlier, now several years out of date. Since these predate AMD support and its accompanying reorganization, examples in these books almost invariably rely on things that are now deprecated and no longer best practice. Most authors are waiting for Dojo 2.0 before publishing anything new.[17]

Learning curve

Many have commented that Dojo seems difficult to learn and get started with, especially in comparison with the more popular jQuery.[18] [19]

Dojo co-creator Dylan Schiemann acknowledges this as a consequence of their different scopes: "It's certainly easier to learn something that's smaller than something that does more, but our avid users are quick to point out that a bit more learning up front saves them countless hours for things that Dojo makes easy."[13]

API stability

Early users faced a difficult transition to the 1.0 release after the toolkit was totally rewritten.[16] The move to AMD in recent versions has been similarly problematic.[19] Dojo has taken great pains to maintain backward compatibility despite its rapid evolution, with a large portion of the current API deprecated but still maintained, but users have often found that upgrades did not go as smoothly as hoped.

Dojo 2.0 release removed much of the deprecated API and switched from JavaScript to TypeScript.

See also

Further reading

External links

Notes and References

  1. Web site: Dojo Blog. dojo.io. 16 January 2024.
  2. Web site: Release v8.0.0-beta.3 · dojo/framework · GitHub. . 2021-03-02. github.com . 2021-03-10.
  3. Web site: Samples · TypeScript. dead . https://web.archive.org/web/20160327042908/http://www.typescriptlang.org/samples/index.html . 2016-03-27 .
  4. Web site: Dojo Toolkit License. Dojo Toolkit. 17 April 2017.
  5. Web site: A Brief History of Dojo — The Dojo Toolkit - Reference Guide. dojotoolkit.org. 16 January 2024.
  6. Web site: jQuery Foundation and Dojo Foundation to Merge. 1 September 2015. Official jQuery Blog. en-US. 2018-07-02.
  7. News: jQuery Foundation and Dojo Foundation to Merge. 1 July 2015. PRWeb. 2018-07-02.
  8. News: Announcing the JS Foundation!. 2016-10-17. SitePen. 2018-07-02. en-US.
  9. Web site: What is Asynchronous JavaScript and XML (AJAX)? . 2023-07-04 . TheServerSide.com . en.
  10. Web site: Adobe Flash Player Version Penetration. Adobe website.
  11. Web site: Dojo Data . 2007-01-11 . 2007-02-03 . https://web.archive.org/web/20070213220902/http://manual.dojotoolkit.org/Book105 . 2007-02-13 . dead .
  12. Web site: Development and JavaScript Blog.
  13. Web site: An Interview with Dojo Toolkit Creator Dylan Schiemann. Nettuts+. 2012-08-16 . 2012-11-21 .
  14. Web site: Dojo 1.7 Released!. Dojo Toolkit Blog. 2011-01-01 . 2012-11-21 .
  15. Web site: What's coming in Dojo 1.8. Dojo Toolkit Blog. 2012-02-09 . 2012-11-21 .
  16. Web site: what is the raison detre for dojo 2.0. dojo-contributors. 2012-10-11. 2012-11-29.
  17. Web site: jQuery and the long term viability of Dojo. Schiemann. Dylan. Dojo-interest. 2012-04-30. 2012-11-29. 2014-10-29. https://web.archive.org/web/20141029133029/http://mail.dojotoolkit.org/pipermail/dojo-interest/2012-April/066087.html. dead.
  18. Web site: Criticism of Dojo?. Seven Foot Tall Cactus. 2012-08-17. 2012-11-21. https://web.archive.org/web/20121026095745/http://blog.kitsonkelly.com/2012/08/criticism-of-dojo/. 2012-10-26. dead.
  19. Web site: Dojo or JQuery. NotADojoGuru. 2012-04-06 . 2012-11-21 .