This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JQuery vs Ajax Frameworks

 
Sergio Ramírez
Greenhorn
Posts: 12
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64182
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Yehuda Katz
Author
Greenhorn
Posts: 21
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3381
Mac MySQL Database Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 !
 
Paul Michael
Ranch Hand
Posts: 697
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
With all the DOM manipulations mentioned, how does jQuery's performance differ from the rest of the frameworks?

Thanks a bunch.
 
Hussein Baghdadi
clojure forum advocate
Bartender
Posts: 3479
Clojure Mac Objective C
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64182
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3479
Clojure Mac Objective C
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

That is exactly what I found horrible to read & write.
To be honest, I'm allergic to JavaScript
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64182
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic