administration mode
Pssst...Ferdy is the creator of JungleDragon, an awesome wildlife community. Visit JungleDragon

 

7 reasons why you really should learn jQuery »

FERDY CHRISTANT - FEB 2, 2009 (06:06:39 PM)

In the last 2 or 3 years, we have all experienced the comeback of javascript. A language cursed in many ways, for its lack of consistency across browsers, slow runtime performance and poor tooling (debugging). The revival of Javascript is hard to miss though, given the jungle of frameworks and effects libraries that are becoming available. Even browser manufacturers are jumping on this trend by delivering javascript engines that dramatically speed up javascript execution. Javascript "2.0" seems to be the fuel for the next generation of web applications. 

For long I have more or less ignored this whole trend. Most developers have enough new things to learn already, and javascript is often not the top priority. The fact that there are a lot of different frameworks (MooTools, Dojo, Prototype, jQuery, etc) does not make it any easier either.

Below are my 7 reasons why you should learn a javascript framework, and that the best one to learn about is jQuery.

1. jQuery seperates behavior from markup

In HTML markup it is still quite common to see things like this:

<form id="myform" onsubmit=return validate();" >

Even though the validate() function can be placed in an external file, in effect we are still mixing markup with logic and events here. jQuery allows you to completely seperate the two. With jQuery, the markup would look like this:

<form id="myform">

Next, the seperate JS file will contain the following event subscription code:

$("myform").submit(function() {
...your code here
)}

This allows for very clean markup with a lot of flexibility. jQuery takes javascript out of your markup, much like CSS took the style out of markup years ago.

2. Write less, do more

Write less, do more - it is the jQuery slogan, and it is an accurate one. Using jQuery's advanced selectors, you can do amazing things in just a few lines of code. You do not need to worry about browser differences (much), there is full Ajax-support and many other abstractions that make you more productive. jQuery takes javascript to a higher level. Here's a very simple example:

$("p.neat").addClass("ohmy").show("slow");

That little snippet loops through all <p> elements with the class "neat" and then adds the class "ohmy" to it, whilst slowly showing the paragraph in an animated effect. No browser checks, no loop code, no complex animation functions, just one line of code!

3. Performance

Out of the big Javascript frameworks, jQuery understands performance best. The minimized and gzipped version is only 18K in size, despite tons of new features in various releases, this number has hardly changed. With each release, major performance improvements have been made. This article is telling of the raw speed of jQuery and the focus that their developers have on it. Combine this with the new generation of browsers (Firefox 3, Google Chrome) that have fast javascript engines on board, and you have a whole new wealth of possibilities in creating rich web applications.

4. It is a "standard"

JQuery is not an official standard, let that be clear. However, the industry support for jQuery is overwhelming. Google uses it, and even hosts it for you. Dell, Digg, Wordpress, Mozilla and many others use it too. Microsoft is even shipping jQuery with Visual Studio. With so much weight behind this framework, you can consider it a safe choice for the future, and a safe bet to invest time in.  

5. Plugins!

There are thousands of plugins developed on top of jQuery. You can use it for form validation, galleries, field hints, animation, progress bars, you name it, it is available. The jQuery community is an eco-system, not just a library. This further supports reason #4, it is a safe choice. By the way, did you know that jQuery actively works together with their "competitors", such as Prototype. It looks like they're here to improve the overall state of javascript, not just for their own benefit.

6. It costs you little time

Of course it will cost you time to truly learn jQuery, especially if you will be writing lots of code or even your own plugins. However, you can do this in bits and pieces, there are tons of examples out there and it is really easy to get started. My advise is to first have a look in the plugin pool before you code something yourself. Next, have a look at the actual plugin code to see how it works. In short, learning jQuery is no huge investment, you can be productive right away and increase your skill in small increments.

7. Fun

I found working with JQuery to be a lot of fun. It is fresh, short and you quickly get results. It solves many nagging javascript problems and annoyances. I used to hate javascript coding but (somewhat) enjoy it now. With the basics fixed, one can now really think about developing next-generation web applications, without being slowed down by an inferior language or tool. I believe in the "Write less, do more" slogan.It is true.

What is not good about jQuery 

Of course jQuery is not perfect. So far, I have experienced the following jQuery caveats:

  • Not backwards compatible. Each new release is not by definition backwards-compatible with earlier releases. For example, sometimes some kind of selectors are deprecated. Instead of keeping them supported, jQuery simply removes them from the new release. This can break your code or that of plugins.
  • Plugins-compatibility. Related to the previous point: when there is a new jQuery release and you want to upgrade, it will depend on your plugin author whether you can upgrade. Quite often existing plugins will break in the newest jQuery release. The more plugins you use, the bigger the chance this will happen. I once fixed a 3rd party plugin because I wanted to upgrade to jQuery 1.3, so you do not always have to wait for others.
  • You can quite easily come in a conflicted state when you use multiple plugins on the same page, particularly when they tie to the same event or selectors. This is not due to jQuery itself, but still a problem that is hard to debug and fix.
  • JQuery does not leave me with an impression of stability. It does not crash my browser, I'm talking about their release policy. Just days after the major new release 1.3, a bug fix release 1.3.1 was released. They also remove functionality that they classify as deprecated, potentially breaking a lot of code. I'm hoping these kind of breaking changes will be limited in the future.
  • Out of the big frameworks, the jQuery core library has relatively poor support for animation and effects. However, in practice this is not problem at all. There is a seperate jQuery UI project and tons of plugins for these kind of things.

Conclusion

My opinion is that if you have these questions:

  • Should I learn a javascript framework?
  • If so, which one?

My answers would be "yes", and "jQuery". This is not to say the other frameworks are not good, it's just that jQuery looks like the most safe and rewarding investment of your time.

Do you agree?

Share |

Comments: 21
Reviews: 14
Average rating: rating
Highest rating: 5
Lowest rating: 4

COMMENT: SAGAR

FEB 2, 2009 - 08:02:58 PM

comment » I 100% agree with you. We do lots of Portal and Domino development so we started with Dojo because IBM uses it in portal. We found dojo poorly documented. Recently we started with jQuery and it is so easy to use with lots of good documentation and real world examples. Productivity of our development team is increased and we are able to build much RICH client applications easily. «

COMMENT: HENNING HEINZ emailrating

FEB 2, 2009 - 22:00:34

comment » I have been using jQuery for about 1 year. My initial approach was quite pragmatic. As the project was a public website, size was an issue and I just decided to take the smallest of all popular JS frameworks. While diving through the documentation and examples I soon discovered that jQuery is a gem. Unfortunately since using jQuery my ambition to fight with Dojo is quite low. «

COMMENT: DILEEP K SHARMA emailhomepagerating

FEB 3, 2009 - 11:03:55 AM

comment » Very informative and very inspirational. Thanks Ferdy for sharing your thoughts on this. «

COMMENT: VIVEK emailhomepage

JUL 1, 2009 - 07:53:38 AM

comment » I m very much a beginner in JQuery and yet i do feel that JQuery is much simler than raw JavaScript,even thiugh i do accept that basically JQuery too is JAvaScript.I 100% agree with ur article.Jquery really is fun to code with. «

COMMENT: 4WARD emailrating

AUG 13, 2009 - 09:34:14

comment » It's very usefull. I'll add this site in my library. Thank you very much!!! «

COMMENT: BILL PARADIS emailhomepagerating

JAN 11, 2010 - 11:54:10 PM

comment » I am about three years into converting our business-to-business in -person business model into an easy to use on-line web application. It is very database and content intensive so I have not spent much time on the glitter aspects. Just getting into jQuery, I find that it is a gold mine of making otherwise difficult JavaScript stuff easy to do. «

COMMENT: VIJAY emailrating

NOV 6, 2010 - 04:19:09 PM

comment » As a beginner to jQuery. This piece of stuff is really good motive to start. «

COMMENT: NORBERT VIETEN emailrating

APR 27, 2011 - 12:23:32

comment » As an experienced web developer i confirm the validity of the seven reasons to learn jQuery. No more pain while developing JavaScript which works on different browsers, lot of fun while developing and enthusiasm that little code make great things posible are my reasons for learning jQuery.

Don't care about the backward compatibility I like that the jQuery developers are so consistently remove deprecated stuff. This helps to keep the framework fresh and small. «

COMMENT: WEB DIZAJN CRNA GORA emailhomepagerating

MAY 18, 2011 - 02:00:32

comment » I have just started with this, thanks «

COMMENT: NARENDRA

OCT 5, 2011 - 03:00:24 PM

comment » Very useful information about jQuery and very inspirational. Thank you. «

COMMENT: GOPAL emailhomepage

NOV 8, 2011 - 06:15:10 AM

comment » I have been using jQuery for about 1 year. My initial approach was quite pragmatic. As the project was a public website, size was an issue and I just decided to take the smallest of all popular JS frameworks. «

COMMENT: VENKAT emailrating

NOV 11, 2011 - 06:49:52 AM

comment » This is Great time to learning JQuery.................. «

COMMENT: ARUL rating

NOV 14, 2011 - 05:18:05 PM

comment » Great intro for begginers like me... «

COMMENT: PREDUZECA CRNA GORA emailhomepage

FEB 26, 2012 - 07:56:31 PM

comment » This is so nice, thanks a lot «

COMMENT: GOPI emailrating

JUN 11, 2012 - 05:58:47 AM

comment » Thanks for the useful info «

COMMENT: EDDY rating

JUL 6, 2012 - 12:30:55 PM

comment » fully agreee budddy «

COMMENT: POOJA rating

AUG 13, 2012 - 09:37:04 AM

comment » Great intro for beginners like me... «

COMMENT: SUDEEP rating

AUG 28, 2012 - 07:48:34 AM

comment » None «

COMMENT: MATTHEW emailhomepage

MAR 3, 2013 - 06:04:47 AM

comment » Shouldn't this:

$("myform")

Be this:

$("#myform")

?? «

COMMENT: FERDY

MAR 4, 2013 - 10:22:56 PM

comment » @Matthew: Well spotted, you are right. «

COMMENT: PARAM emailrating

OCT 11, 2013 - 10:24:16 AM

comment » very useful for me really rocks.... «

RATE THIS CONTENT (OPTIONAL)
Was this document useful to you?
 
rating Awesome
rating Good
rating Average
rating Poor
rating Useless
CREATE A NEW COMMENT
required field
required field HTML is not allowed. Hyperlinks will automatically be converted.