6

With the availability of JQuery, is there any need to learn direct DOM manipulation with Javascript in order to be a professional web developer/site builder/etc.?

This probably could be asked with Prototype, MooTools, etc. too, but I'm not familiar with them apart from their names.

Paul D. Waite
  • 96,640
  • 56
  • 199
  • 270
Baruch
  • 20,590
  • 28
  • 126
  • 201
  • 2
    Is knowledge of CPU architecture obsolete given the availability of scripting languages? – JUST MY correct OPINION Dec 05 '10 at 12:51
  • 1
    You need that knowledge to design your algorithms better. – Lockhead Dec 05 '10 at 12:54
  • 1
    Should a professional developer be depending on other developers and have to trust them blind? – Dr.Molle Dec 05 '10 at 12:58
  • 1
    @Dr.Molle Isn't that what you do anytime you use any framework, API or even compiler? (.NET, Drupal, Java, GCC, Win32API are just some common examples) – Baruch Dec 05 '10 at 13:01
  • 1
    @baruch: I personally only ever program for CPUs that my own fabrication facility made to my exact specifications, using languages that I’ve written myself. Anyone who does differently is a **rank amateur**. – Paul D. Waite Dec 05 '10 at 13:10
  • @baruch: maybe there is a difference between trusting developers of a browser and developers of a javascript. However, if a client likes do have an application done without any framework, you are professional without an order. – Dr.Molle Dec 05 '10 at 13:25

5 Answers5

5

Note: This question was rephrased so my answer reflects the initial question but I kept on adding.

Absolutely. Jquery IS Javascript and while it does abstract a lot of the cross-browser DOM discrepancies, one is still prone to the same exact parsing errors, scope misunderstandings, and so forth.

Using jQuery without knowing basic DOM knowledge or necessary Javascript knowledge is what I would consider dangerous, somewhat like giving a very powerful gun to a child who just may accidentally shoot himself in the foot without knowledge of how to use such a powerful tool the proper way.

A person that's taught straight with jQuery would have absolutely no idea how to debug issues if the error being thrown refers to anything in the DOM. For something as simple as comparing to see if an element is another element ( for things like current state ), they would try something maybe like:

if ( $('a.current') == $('a.current') ) { }

Which would return false since two unique jQuery objects are created. If they had known how to grab the reference to the DOM nodes they could have just done $('#el')[0] == $('#el')[0].

Anytime you use a jQuery plugin and run into some mysterious behaviour, without DOM knowledge you pretty much have to rely on someone else to help you out. Developers with DOM knowledge would be more able to debug and know the root of the problem, so you're only setting yourself up to lose more time scratching you head puzzled in jQuery land.

Furthermore, if one wishes to ever get to a high knowledge level and not just be an ordinary joe jQuery developer then he would greatly need a vast knowledge of the DOM discrepancies and Javascript in general otherwise you're limiting your skill level by a huge margin.

If you stick around Stackoverflow for awhile you'll see this in day to day questions, in which people who took the easy shortcut lack the basic JS/DOM knowledge necessary to solve their issues.

meder omuraliev
  • 183,342
  • 71
  • 393
  • 434
  • I meant is the knowledge of how to manipulate the DOM directly obsolete, not the Javascript syntax. – Baruch Dec 05 '10 at 12:57
  • 4
    Dare I link to the infamous [-1, not enough jQuery](http://www.doxdesk.com/img/updates/20091116-so-large.gif)? ...yes. Yes I do. – David Thomas Dec 05 '10 at 13:13
  • @David +1 for the great link. I've never seen that. I actually laughed out loud. – Baruch Dec 05 '10 at 13:23
  • @baruch, you're welcome; this is one of the two Stackoverflow (almost-) meta links I love. (The other is the [obligatory retort to parsing html with regex](http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454)). – David Thomas Dec 05 '10 at 13:45
  • @David: +1 Funniest thing i've seen all day – Jules Colle Dec 05 '10 at 14:56
2

In some circumstances, you could conceivably not want the overhead of a DOM manipulation library.

E.g. for mobile development, mobile internet connections are still a bit slow at the moment, so you might want to save bandwidth by forsaking a library and going with native DOM code. (And possibly save a bit of execution time, as mobile devices are currently a bit slower at running JavaScript than desktop computers.)

But the devices, libraries and internet connections should all get faster as time goes on, so I reckon it’s unlikely you’ll do a lot of direct DOM scripting in mainstream day-to-day web development.

Paul D. Waite
  • 96,640
  • 56
  • 199
  • 270
2

If you don't want to learn the underlying basics, sure it is :)
If you're not interested in how stuff works, sure it is....
If you want to cry for help each time you hit the limits of jQuery, sure it is!
If you want to depend on people here answering you simple questions, sure it is :D (reps for us...)

"The fool wonders the wise man asks."

In other words, know how the tools you use work, otherwise you'll end up with a horrible dependency.

Ivo Wetzel
  • 46,459
  • 16
  • 98
  • 112
2

You can use a library like jQuery with little knowledge of Javascript and almost no knowledge of the DOM, but that will only get you as far as the library lets you. You will only be able to do things that others have done before you.

Knowing how the underlying system works will also let you use the library more efficiently. Knowing what the library has to deal with lets you know why there is a big performance difference for certain ways of using the library, and why some things doesn't work at all.

Guffa
  • 687,336
  • 108
  • 737
  • 1,005
1

There's a great many things that jQuery simplifies for you, but knowledge of the underlying JavaScript that jQuery calls can make things a little faster:

$('<div />').appendTo($('body'));

and

$(document.createElement('div')).appendTo($('body'));

are both equivalent, but the latter is a shade faster (albeit only in the order of milliseconds), since you're using JavaScript directly, rather than having jQuery calling document.createElement() on your behalf. Again, this is definitely a ridiculous micro-optimisation.

Other examples are working with Date, Math and string objects/functions. jQuery doesn't implement replacements for these (wisely so, since they're fairly easy to work with already).

David Thomas
  • 249,100
  • 51
  • 377
  • 410
  • I meant is the knowledge of how to manipulate the DOM directly obsolete, not the Javascript syntax. – Baruch Dec 05 '10 at 12:58
  • “the latter is a shade faster” — is it always? Will it always be? **Unsubstantiated optimisation alert** – Paul D. Waite Dec 05 '10 at 12:58
  • 3
    @Paul, perhaps not **always**, but consistently in my testing so far it has been. I can only link to one demonstration, though: [JS Fiddle demo of assertion](http://jsfiddle.net/davidThomas/57fvJ/). Also, please note that I *was* very clear that it is a **ridiculous micro-optimisation**. – David Thomas Dec 05 '10 at 13:01
  • @David: nice one. (Although query how many browsers you tested in?) – Paul D. Waite Dec 05 '10 at 13:03
  • Tested in Chrome (whatever the latest Chrome was when I wrote it), FF3.x, Opera 10.x (Win XP SP3/Ubuntu 10.04/Ubuntu 10.10) and also IE 8 (Win XP SP3). I can't post all the numbers, since I never recorded them, but it's usually around 25% (±10%) faster using the `document.createElement()` version. – David Thomas Dec 05 '10 at 13:06
  • @Paul, thank you kindly. Um, if anyone feels like running this through Mac browsers, I'd be interested in those numbers... =) – David Thomas Dec 05 '10 at 13:10
  • @David: oh, I had a look on Chrome 7, Opera 10.62 and Firefox 3.6 on the Mac, I got similar results to you. – Paul D. Waite Dec 05 '10 at 13:18