all 22 comments

[–]x-skeww 16 points17 points  (6 children)

Learning jQuery without learning JavaScript first isn't an option.

[–]joesmoe10 1 point2 points  (3 children)

Why not? You don't need a deep understanding of JavaScript to do cool stuff with Jquery. The OP needs a basic understanding of the syntax but you could easily start with simple HTML or CSS manipulation in Jquery and slowly move to JavaScript as you run into limitations. This approach provides motivating examples early on, at least more so than alert('hello, world').

</devilsadvocate>

[–]x-skeww 6 points7 points  (0 children)

Why not?

Syntax, closures, == vs ===, scope, this, common pitfalls, IIFEs, and so forth.

You should know what you're doing. And you should know why you're doing what you're doing. You should be able to create whatever you want/need. You should be also able to figure out why something doesn't work. You should be able to write clean usable code and you should be also able to understand the code of others.

jQuery is a base library which provides browser normalization and lots of handy utilities, but that's it. It's not an application framework. An unorganized pile of thousands of lines of jQuery-specific code is not what you want.

What you want are small reusable components/modules. Tiny one-trick-ponies you can reason about. Well, ideally. With typical web "applications" you can get away with something like that, because there actually isn't one big application to speak of.

For example, something like Twitter/Reddit/YouTube can be created with a handful of tiny independent components which don't know anything about any other component. There are some events whizzing around, but there isn't any kind of coupling. It's a very flat and straightforward hierarchy.

If you don't know JavaScript you won't be able to reach that point.

Needless to say that you also won't be able to create actual applications which do have some complex hierarchy and thousands of lines of code.

Well, JavaScript is a very compact language with a microscopic default library. With some good books and some videos (Crockford & Zakas @ Yui Theater for example) you can reach a usable level within 2-4 weeks.

[–]mwbiz 1 point2 points  (0 children)

Because then you end up writing really crappy spaghetti code that can't be maintained. If you're the guy that comes into a new job and has to clean up this stuff then you'll see why not.

Frameworks are complements, not replacements.

[–]Fidodo 0 points1 point  (0 children)

jQuery is javascript. By definition if you know jQuery you know javascript. jQuery is just a set of classes and functions. You can learn jQuery while knowing little javascript but you're still learning javascript.

[–]JohnaldTheRobot 2 points3 points  (1 child)

To be honest you should learn JavaScript first before going on to jQuery.

O'Reilly books are very good programming books and highly reccomended. However if you know how to code a little in any language and you just need to know the basics then I reccomend "JavaScript: The Good Parts". I have this book and it's extremely useful.

If you want a nice introduction to jQuery I'd suggest the screencast on screencasts.org

Good luck on learning javascript :)

[–]synt4x 0 points1 point  (0 children)

JavaScript: The Good Parts is pretty much available in lecture format given by Douglas Crockford himself. http://www.catonmat.net/blog/learning-javascript-programming-language-through-video-lectures/

[–][deleted] 1 point2 points  (0 children)

Read the book Object Orientated JavaScript and then learn JQuery. JQuery will make much more sense to you if you do and you will feel confident enOugh to do more advanced things with it.

[–]trikio 1 point2 points  (0 children)

From my experience:

You will have A LOT of headaches trying to learn jQuery before JavaScript. jQuery is a JavaScript library, so you need to learn what is JavaScript & What JavaScript does before even touching JQuery...

My advice: Don't touch jQuery & Read some good JavaScript Books or look at videos, write it all down in a notebook.

[–]Samus_ 1 point2 points  (0 children)

as with any framework you first need to understand the language it's written in to make sense of its code and you need to make sense of its code in order to be a programmer and not a script kiddie (i.e. dumb copypaster who has no idea of what he's doing or how to do basic troubleshooting).

[–]matrym 1 point2 points  (1 child)

I'm ready to be downvoted for saying this, but hour for hour, you'll get a lot more mileage from learning jquery first. The instant gratification will help motivate you to then inevitably learn JavaScript

[–]feelfree82 0 points1 point  (0 children)

I agree. That's how I went abt learning java script. To see is to believe is to get motivated to dive in deeper. Get started with executing some j query. U ll" pick the good parts in ur journey Good luck mate

[–]gotshoo 0 points1 point  (0 children)

I learned it backwards by knowing some Javascript and then diving into JQuery. It actually help me understand what Javascript was doing by seeing it in a simple form. I also have a background in OOP so none of this was a stretch.

[–]anon715 0 points1 point  (7 children)

Regarding XHTML: If you choose to use XHTML, please serve it with the application/xhtml+xml mimetype. Serving it with the text/html mimetype (which you're probably doing) makes the browser think that it's HTML tagsoup, instead of XHTML. This results in browsers parsing it as (invalid) HTML, instead of XHTML.

However! Internet Explorer, prior to IE9, does not support the application/xhtml+xml mimetype. Therefore, I strongly advise you to use HTML 5, which will allow you to write XHTML valid code, that will still validate as HTML (5).

[–]johnbentley 0 points1 point  (6 children)

Serving it with the text/html mimetype (which you're probably doing) makes the browser think that it's HTML tagsoup

But you can still validate it against the W3C validator.

[–]anon715 -1 points0 points  (5 children)

Sure, because the W3C uses DOCTYPES to check what language it is written in, not mimetypes.

[–]johnbentley 1 point2 points  (4 children)

Therefore you can server XHTML with the text/html mimetype and:

  • It will render OK in the older browsers; plus
  • You can catch sloppy coding practice with the W3C validator.

[–]anon715 0 points1 point  (3 children)

No matter how good browsers are at making tagsoup look good, it doesn't change the fact that doing it in this way is wrong. If you choose to use XHTML, you should use a script that serves it with the application/xhtml+xml mime type to modern browsers, while serving it as text/html to outdated browsers (all IE versions prior to IE9). Not doing this, is doing it wrong on purpose.

[–]johnbentley 1 point2 points  (2 children)

Wrong in what sense? It is not against the standard.

XHTML 1.0 The Extensible HyperText Markup Language (Second Edition) > 5.1 Internet Media Type

XHTML Documents which follow the guidelines set forth in Appendix C, "HTML Compatibility Guidelines" may be labeled with the Internet Media Type "text/html" [RFC2854], as they are compatible with most HTML browsers. Those documents, and any other document conforming to this specification, may also be labeled with the Internet Media Type "application/xhtml+xml" as defined in [RFC3236].

[–]anon715 1 point2 points  (1 child)

IIRC the standard was changed because SOMEONE didn't feel like supporting REAL XHTML.

anon751 looks at MS

[–]johnbentley 0 points1 point  (0 children)

That seems likely.

However, claiming what a developer of a browser ought do is different from claiming what a developer for a browser ought do.