views:

2957

answers:

18

Is it a good idea to learn JavaScript before learning a JavaScript framework library such as jQuery, Prototype, etc.?

Sometimes I find myself struggling because I feel I don't know JavaScript as well as I should.

+11  A: 

Long as you learn the BASICS in Javascript; HTML document traversing, event handling, etc... you should have no problem learning jquery.

Then from learning the basics you will understand how Jquery is to help you do the things that javascript can do, but with less work.

TStamper
I don't think it's ever wise to offer the advice that "if you learn the basics, you can do more with less work". Learning the basics is just enough learning to get you into trouble.
Justice
@Justice -jquery is a whole another approach of javascript that makes the client do things simpiler, which is what I mean by , with less work..the basics meaning how the client handles the rendered code
TStamper
+21  A: 

Sometimes I find myself struggling because I feel I don't know Javascript as well as I should?

I think you answered your own question.

Jesse Weigert
Hey, that was my comment
Ed Swangren
I don't think anyone should use a framework before learning the underlying language.
Unkwntech
@Unkwntech: it's hard for me to agree. I made wonderful progress in C# *before* learning C and I still don't know C++
Dinah
@Dinah C# isn't a framework built on C or C++, it's a completely different language with roots in its predecessors. It's the same as saying you don't need to know BCPL before learning C.
lacqui
@lacqui: Ok, I see now the distinction you're making. Thanks for the clarification
Dinah
@Dinah: That's different. It would be more like saying you write .NET programs without really knowing C# very well. C and C++ may have historical ties to C# but they do not really underlie it as in the context of Unknwntech's statement.
CodeMonkey1
+35  A: 

An emphatic YES. It won't take as long to learn as you fear and the rewards will be more than worth it.

Dinah
+1  A: 

When I started my switch from VBScript to JavaScript I was immediately enthralled with Jquery. After a short while I started to really understand how JavaScript and Jquery interacted with each other and I became a little confused and frustrated. My issue was with the desire to use the simplicity of Jquery but I felt like I was cheating myself by not learning JavaScript first.

It turned out that I learned both at the same time. As I wrote JQuery routines I found the need to learn JavaScript in order to understand why things worked the way they did and to help make certain Jquery routines work correctly.

I am still learning JavaScript and Jquery but I am much less concerned about becoming a master of JavaScript as I know my understanding will grow as it needs to. It definitely helps to have some basic understanding of JavaScript but I would say you should focus on learning how to accomplish specific tasks and not on learning JavaScript before JQuery...

My $0.02 worth.

Dscoduc
+2  A: 

To some degree, but don't get hung up on object oriented programming like in the java world (in javascript it's prototyping anyway). It would help in the long run to have a good understanding of closures/anonymous function and how the special variable "this" is used (particularly with regards to events such as click) and how functions like "apply" work. I'd also make sure that you really understood CSS selectors as they are a central feature of jQuery and pretty much every other JS framework out there.

You're also going to need to be familiar with how to use the full functionality of firebug.

I'd also assume you have a basic understanding or knowledge of how the DOM works.

That's the start of tinkering in Javascript.

altCognito
+2  A: 

As I see it, jQuery is nothing but a framework to make your life simpler. jQuery itself is written in javascript. So it helps to learn javascript.

Mind you, you need not be a master but should be able to make the necessary changes /work arounds, when what you can do with jQuery alone is not sufficient.

rAm
+3  A: 

Of course, it goes without saying. How can you use jQuery if you don't learn JavaScript first? After all, jQuery is nothing but a library for JavaScript.

hasen j
learning the jQuery API is no substitute from learning and understanding javascript as a language
Greg Dean
+8  A: 

I'll go against the grain and say that, while ideally you would become proficient in JavaScript before learning jQuery, you can probably make great progress on both fronts by jumping in and coding using the library.

One of jQuery's strengths is that it makes it easier to do certain things in the browser. You can get a lot of real work done by cutting and pasting and adapting other people's code, so why not start doing that? As you go, when you encounter an idiom you don't quite understand, dig around and find out what it means or how it works.

Over time, you will become a master of both JavaScript and jQuery.

If you have any kind of programming background, a good book to read to get you up to speed quickly on JavaScript is Douglas Crockford's, JavaScript: The Good Parts.

Andrew Hedges
one need not be proficient with a language.
hasen j
But one would like to be, and one would of course be better off if one were.
le dorfier
+1 It may actually force you to become better faster, since it forces you to use some Javascript idioms you may not otherwise have. E.g. passing functions as callbacks requires you to get used to what exactly functions are and also deal with nested variable scopes.
deceze
I strongly agree with this answer. Granted, the proper thing to do is to learn javascript first and then learn a framework, but to be honest my javascript knowledge was CRAP before I started using jQuery and as I learned more and more about the framework, I learned more and more about the language itself. So basically __jQuery indirectly taught me JavasScript__.
Pandincus
+5  A: 

The answer to your question is a definitive yes. jQuery, Prototype and the rest serve to overcome cross-browser headaches and ease AJAX, UI behaviours, DOM operations etc. You'll end up with some pretty bad code if you are just copy/pasting snippets or have no real understanding of Javascript.

As a litmus test, you should be able to follow everything that is said in this wonderful re-introduction to Javascript. It's a bare minimum for writing good code and may require some more Googling on your part. Only then should you read Willison's equally good introduction to jQuery.

That should provide you a good start to build upon. And then if you feel up to it, you can start digesting Crockford (start with Douglas Crockford — JavaScript: The Good Parts).

aleemb
+3  A: 

Call me old-fashioned, but I think it is best to learn the basics of one tool before moving on to its advanced cousin -- much like being competent with a handsaw before moving on to a circular saw.

If you are struggling, you've answered your own question. I feel you'll be better equipped to make good use of JQuery once you are comfortable with JavaScript.

+2  A: 

The value proposition for jQuery (or any other framework) doesn't only come from what it does with javascript. It also builds on the DOM, HTML, and a number of language-agnostic patterns. And you don't need to understand it all in depth to find frameworks useful. Of course, you'll be better off if you know all the pieces, but we all need to start from something less.

I learned jQuery and javascript simultaneously, and it worked quite well for me that way.

I think the question isn't so much which to learn first, but more to the point, you need to expect to become increasingly familiar with all the pieces and how they work together.

To me it's somewhat (not entirely) the same question as what you need to know before starting with WebForms. Sure it's better if you're already comfortable with C# (and the same DOM and html), but it's legitimate to use WebForms as a vehicle for your education. Same thing can be said for frameworks.

le dorfier
A: 

Just enough to debug your code. Otherwise, you will never be able to figure out what's not working.

TFM
+2  A: 

Suppose you should know the following about Javascript:

  1. How to calculate the X and Y element offset for the absolute/relative positioned DIV for browsers IE6-IE8, FireFox, Opera, Safari (each of the browser has different model for this particular case).

  2. What is closure and how to create it.

  3. How to create onLoad event in the browsers listed above.

  4. Have an example of the HTML/Javascript code where you have pure HTML code like

<a href="" rel="remove">Remove</a>

and javascript code that add special handlers in automatic mode for A tag using "rel" attribute.

After you get acquainted with this you may use jQuery library that hide the complexity of this :)

Regards, Pavel

se_pavel
A: 

Learning JS would make life easier for coding JQuery but I don't see why you should necessarily learn it first. You'll just have to learn it eventually.

+1  A: 

Yes.

You obviously don't need to learn everything about JS. But at least learn the basics, and try to learn some best practices.

For me the trickiest part about Javascript is all the different implementations of it in the different browsers. But there are certain things you can do to help yourself avoid some of those problems. For example, it's usually preferred to use document.getElementById() to access elements in the DOM since it essentially works the same way in all modern browsers. Also, it's almost always best to use feature detection rather than browser detection. Little things like that go a long way in avoiding problems in specific browsers later on.

Fortunately JQuery was written pretty well for cross-browser compatibility, but there may be times when you don't want to use it directly and you may have to rely on your JS skills.

Steve Wortham
+1  A: 

There are really two seperate aspects to JavaScript within the Browser. First, the JavaScript Language, and second the HTML DOM that allows you to manipulate the page using the JavaScript Language.

That said, then YES you should spend time learning the JavaScript Language. I recommend picking up a copy of "JavaScript: The Good Parts" by Douglas Crockford.

Now as to the second part, the HTML DOM. You really don't need to focus too much on learning the ins and outs of the HTML DOM if you are going to use a framework like jQuery. Just do things the "jQuery way" and then pick up as much HTML DOM as is necessary along the way.

Chris Pietschmann
+1  A: 

I think learning events the document object model, and JavaScript forms programming is enough to get started in jQuery.

Treckker
A: 

My first thought was that It's always good to learn something new and Javascript is becoming ubiquitous (now is on the server side too ).

It's seems that you have still not decided the best answer for you and AFAIK this question was posted before March 21 ... I see plenty of time to read at least this that was written by a very talented guy.

If you study javascript you will never come to SO asking question like:

What the keyword this mean in the contest of my snippet of code?

But if you always are in a hurry, without having time to improve your code and If you never have to build jQuery plugins go without Javascript.

microspino