On Feb 26, 12:10 am, Daniel Friesen <[email protected]> wrote:
> jQuery is supposed to simplify things, not force the user to shove ugly
> native DOM code into something programmed in jQuery.

Here is my view...

jQuery exists to normalize browser behavior and to simplify mundane
tasks. It is vital for anyone using jQuery to understand javascript
and be able to write "plain old javascript" (POJS).

jQuery is not a "replacement" for POJS. It's not even a layer on top
of POJS. It is just a tool to do a few common tasks in a different
way. Nothing is "programmed in jQuery", and thinking in that way is a
bad idea.

jQuery is just another API to learn. Reading documentation to learn
what a .detach() method does and then using it is no better than
learning the core .removeChild() method. In fact, it's worse because
if you're in a situation without jQuery, you won't know how to remove
a child node! The advantage to using .remove() is that it does all the
jQuery stuff that might need done.

Trying to encourage people to do everything "the jQuery way" rather
than using POJS is a bad idea. I have seen some terrible and
inefficient code written because people only knew how to do things
"the jQuery way" and end up writing code that is uglier, slower, and
harder to maintain than the POJS they were trying to improve on. When
developers learn only the jQuery way to do things, then they start to
try to solve every problem using it, even when it's not warranted.
When all you have is a hammer, everything looks like a nail.
I've seen this many times:
   var id = $(this).attr('id');
and I just saw this today:
   var tr = $(td).parents('tr:first').get(0);
I refer to this kind of stuff as "jQuery Obfuscation" :)

> You're suggesting instead of creating a simple .detach() method, we
> force programmers to type in
> $('.someMultiNodeSelector').each(function()
> {this.parentNode.removeChild(this);});

Is "forcing" someone to write POJS so bad? :)  I use jQuery often, but
I still write POJS in most cases unless jQuery would make something
significantly easier or more concise, or fix browser quirks that I
don't want to do myself.

Matt Kruse

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"jQuery Development" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/jquery-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to