Does jquery replace the need for dojo?
I am starting a new project using the PHP Zend framework.
Now that jquery is fairly mature, is dojo no longer needed?
I do not mean for this to be an opinion question. A valid answer could be that they b开发者_运维百科oth still are viable.
Thanks!
Depends on your needs. If all you need is XHR and DOM manipulation, you can probably pick any well-known library out there. But if you're looking for stuff beyond that, Dojo gives it to you. jQuery...doesn't, really (at least not without looking around for plugins, and then you're getting into YMMV territory).
Whenever anyone asks something like this I always point them to Rebecca Murphey's excellent blog post pointing out what kinds of things jQuery doesn't really consider:
http://rmurphey.com/blog/2010/08/09/on-jquery-large-applications/
Some examples of things Dojo gives you that jQuery doesn't OOTB:
- Modularization and dependency management system
- RequireJS is popular for this among jQuery users; interestingly, it's now a Dojo Foundation project, and its module format will also be usable in Dojo 1.6.
- Inheritance framework (
dojo.declare
) - Fully skinnable/extensible widgets with WAI-ARIA support (
dijit
, with more indojox
) - Consistent data APIs (used by more data-intensive widgets such as Select, ComboBox, FilteringSelect, and
dojox.grid
) - Pub/sub framework for communicating across an application without necessarily directly binding together unrelated components
- Peter Higgins, the Dojo maintainer, actually wrote a plugin to bring this and some other Dojo niceties to jQuery; it's available here: https://github.com/phiggins42/bloody-jquery-plugins
- Hash support (
dojo.hash
since 1.4)- http://benalman.com/projects/jquery-bbq-plugin/ is a rather nice jQuery plugin for this functionality.
- Build script for rolling your own custom build of Dojo with layers containing all your app's dependencies consolidated into one script.
You can't necessarily do a one to one comparison. Dojo is a different beast really... It is highly more architected and thus isn't as simple to use, but with this tradeoff for simplicity you get a much more robust and programmatically extensible JS framework.
Personally I'm not a big fan of Dojo since I don't typically develop JS applications like GMail or what have. I think this is the context where Dojo really shines. But if all you need to do is add some ui widgets and manipulate the DOM I think jquery is the better choice.
To answer your question directly: No, jQuery does make Dojo any less or more needed. And in my eyes jQuery 1.2.6 was as mature as Dojo and this the maturity level of the projects has never been a consideration since I started using ZF - it's always been about the needs of the project and how/what features are implemented in each.
精彩评论