What is dojo? Macro comparison with jQuery, what is the result?

DojoWhat can you do? ?

1, to make it easier for developers to add dynamic capabilities to Web pages, and Dojo can also be used in other environments that support JavaScript;

2, using the components provided by Dojo, developers can improve the usability and interactive capabilities of Web applications;

3, Dojo largely shields the differences between browsers, so developers don’t need to worry about whether Web pages are available in some browsers;

< p style="line-height:25px; margin:0in; color:rgb(51,51,51); font-family:Georgia,'Times New Roman',Times,sans-serif; font-size:10.5pt" > 4, through the tools provided by Dojo, you can also write command-line unit test code for the code.

5, Dojo’s packaging tool can help you optimize JavaScript code, and only generate the minimum set of Dojo packages required to deploy the application.

6,… etc.

Dojoarchitecture (only part of the package, found online)

< /p>

FirstThe layer is Dojo’s Widget system. Widget refers to an element in the user interface, such as buttons, progress bars, and trees. Through Widget, you can operate buttons, menus, etc., including style and event handling. Just add simple tags to the page.

The second layer is the application support library,dojomost of the code They are all placed on this layer. Most of the time we call the API in this layerAPI span>.

The third layer is environment-related packages, The function of this package is to deal with cross-browser issues.

The fourth layer is the language library, which contains Some language tool APIs are similar to Java’s util package.

The bottom layer is the package system, the structure of the Dojo API Similar to Java, it divides all APIs into different packages. When you want to use an API, you only need to import the package where the API is located.

The above picture is just the hundreds of packages provided by Dojo For one part, these packages are put into three first-level namespaces: Dojo, Dijit and DojoX. Among them, Dojo is the core function package, Dijit stores all Dojo Widget components, and DojoX is some extensions or test functions. The test functions in DojoX may be moved to the Dojo or Dijit namespace in subsequent versions after they are mature. .

JqueryandDojoMacro comparison:

First of all, it is not absolute.

1, frame size

Dojo is a heavyweight development framework. It consists of the framework core (dojo), basic control library (dijit), The expansion package (dojox) is composed of three parts which are officially provided by dojo;

jQuery is a lightweight framework that only contains the core of the framework. In addition, there is an independent open source project jQuery UI under the name of jQuery, which provides the 8 most commonly used controls.

not absolute,If you use jquery like With dojo, dojo is a lightweight js library.

If you Use jqueryui+jquery, then jquery is a heavyweight js library.

2, programming method

Dojo uses object-oriented programming to provide a guarantee for large-scale application development;

jQuery uses functional programming, which makes it even more important when developing small applications Flexible and fast.

Dojo has enhanced its object-oriented capabilities based on Javascript And standardization, it provides object-oriented programming capabilities that native Javascript does not have, such as parent class method overloading (note, not rewriting), multiple inheritance, constructor call chain, etc., and provides a series of object-oriented programming standard functions and The attributes declare, inherit, declaredClass, extend, etc. are used as the programming basis of dojo itself. In dojo, all UI controls are defined as classes, and many of Dojo’s core function libraries are also defined as classes, all for the sake of better code reusability.

Javascript is essentially a functional programming language. jQuery does not change the way Javascript is programmed, which greatly reduces the cost of learning . It’s not like thatjquery can’t do object-oriented programming at all, It’s just not necessarily soDojoSo intuitive, useJqueryThe same can be used for inheritance, the same in writingthis. Each has its own insights.

3, code style

Except for jQuery’s iconic “$” symbol, in fact, the naming and parameter lists of dojo and jQuery are basically similar on some common APIs.

4, learning cost

From the above analysis, we have removed Javascript, which is essentially a functional programming language. jQuery has not changed the way Javascript is programmed, which greatly reduces the cost of learning.JavascriptBasic programming is easy to get started. But if you want to make an interface with a higher user experience, technology alone is not enough. BecauseDojoand< /span>JqueryBoth code style Similar, so there areJqueryBasics, learningDojoNot very difficult. On the contrary, there isDojoBasic , Let’s learn againJquery It’s not difficult.

5< span lang="zh-CN" style="line-height:1.8; font-family:SimSun">, scope of application

Dojo is more prominent in object-oriented support, code architecture, multi-polar module loading mechanism, control integrity, etc. The characteristics of this, suitable for enterprise-level or complex large-scale Web application development;

jQuery architecture and mechanism are relatively simple, easy to develop, widely used, and suitable for relatively simple Web 2.0 development.

Dojo and jQuery are designed for complex application development and simple application development respectively,But not absolutely, it depends on how the developer uses it. If it is an application with too much UI interaction, choose dojo,But if you chooseJquery+Jquery UI is also a good way.

In actual projects, it is necessary to measure and choose tools according to specific needs.

Haha, it seems that all the comparisons should be the specific analysis of specific issues, and this article is also the case. I don’t want to mislead everyone.

Leave a Comment

Your email address will not be published.