aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes JQuery vs Ajax Frameworks Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "JQuery vs Ajax Frameworks" Watch "JQuery vs Ajax Frameworks" New topic
Author

JQuery vs Ajax Frameworks

Sergio Ramírez
Greenhorn

Joined: Nov 08, 2007
Posts: 12
Hi all

How do i compare JQuery against other ajax frameworks, like ZK, Prototype...
Could you give a comparation?


Sergio
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61043
    
  66

See this topic for an overview of jQuery.

jQuery is not a framework per se, but more of a JavaScript library such as Prototype, but with a bit of a different approach (see linked thread).

And while jQuery has really great support for Ajax, it's not just an Ajax library. It has full support for all types of DOM manipulation, event handling, effects and animations, and all other manner of useful things that you usually need to do in JavaScript.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Yehuda Katz
Author
Greenhorn

Joined: Jan 14, 2008
Posts: 21
jQuery sets itself apart by focusing heavily on DOM manipulation and traversal. Because it's central core is based around getting elements and doing things with them (show, hide, fadeIn, fadeOut, load contents from Ajax, etc.), virtually all plugins integrate into the library as though they were part of the core.

For instance, in jQuery you can do:
$("div.hidden-contents").addClass("shown").fadeIn("slow").load("some_url_for_ajax").

If you loaded in a (hypothetical) tree plugin, you could do:

$("div.tree").addClass("shown").load("url_with_tree_contents").tree().fadeIn("slow")

Pretty cool, huh?

In contrast, Prototype's raison d'�tre is to make JavaScript more like Ruby. MochiKit's is to make JavaScript more like Python, and so on.

jQuery takes the approach that JavaScript is a neat language that is used primarily for DOM scripting, but with a pitiful amount of built-in DOM functionality. It aims to fix that.

Hope that was helpful
Raghavan Muthu
Ranch Hand

Joined: Apr 20, 2006
Posts: 3344

Originally posted by Yehuda Katz:

jQuery takes the approach that JavaScript is a neat language that is used primarily for DOM scripting, but with a pitiful amount of built-in DOM functionality. It aims to fix that.

Hope that was helpful


Yes very much it was helpful Yehuda Katz [for a beginner like me]

Thank you !


Everything has got its own deadline including one's EGO!
[CodeBarn] [Java Concepts-easily] [Corey's articles] [SCJP-SUN] [Servlet Examples] [Java Beginners FAQ] [Sun-Java Tutorials] [Java Coding Guidelines]
Paul Michael
Ranch Hand

Joined: Jul 02, 2001
Posts: 697
With all the DOM manipulations mentioned, how does jQuery's performance differ from the rest of the frameworks?

Thanks a bunch.


SCJP 1.2 (89%), SCWCD 1.3 (94%), IBM 486 (90%), SCJA Beta (96%), SCEA (91% / 77%), SCEA 5 P1 (77%), SCBCD 5 (85%)
Hussein Baghdadi
clojure forum advocate
Bartender

Joined: Nov 08, 2003
Posts: 3479

I find jQuery code is hard to read and write, it is kind of obfuscated (at least to me)
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61043
    
  66

That's odd. After all, it's only JavaScript. I find it quite the opposite since when using jQuery on a page, the code tends to follow a similar pattern rather than just a jumble of code styles.

Is it the use of $ that you are not used to? Unfamiliar with CSS syntax so that the selectors look odd to you?

When using jQuery, most JavaScript statements form a wrapped set using the $() function, and then jQuery methods (called "commands" in the book) are applied. So a typical statement might be:


Once you get used to this pattern, since it is used so ubiquitously, it becomes very easy to figure out what's happening.

Some of the more advanced selectors (the expression that is passed to the $() function) can be complex, but that's CSS syntax and can be as complex or as simple as you like.
Hussein Baghdadi
clojure forum advocate
Bartender

Joined: Nov 08, 2003
Posts: 3479


That is exactly what I found horrible to read & write.
To be honest, I'm allergic to JavaScript
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Originally posted by John Todd:
To be honest, I'm allergic to JavaScript


Which lends no wait to JQuery being difficult to read. I too found it "different" when I first started using it. Why? Because I was using prototype which takes a more OO approach to JavaScript. But once I realized what was happening with JQuery and the power of CSS Selectors and Chaining I realized it wasn't difficult to read anymore. How long did this realization take? About half way through chapter 2 of JQuery in Action.


GenRocket - Experts at Building Test Data
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61043
    
  66

Originally posted by John Todd:
To be honest, I'm allergic to JavaScript

Well then, it isn't jQuery syntax you're having an issue with. That's sort of like saying, I don't like the java.util.text package because I don't like Java.

Seriously, I think that when people first see jQuery code, it's the $ that throws them if they haven't see it used as an identifier before, and perhaps the syntax of the more advanced selectors (which people love to throw around as examples).

If you replace the $ with jQuery ($ is just an alias for the jQuery() function for brevity) and use a simple selector, it's clear that all jQuery code is doing is run-of-the-mill JavaScript function calls.

Perhaps many people also aren't use to chaining JavaScript function calls -- a very common and useful thing to do -- and perhaps that could throw them a bit at first.

But the heart of jQuery is the pattern:

Everything else just builds upon that.
 
Don't get me started about those stupid light bulbs.
 
subject: JQuery vs Ajax Frameworks