When to use Vanilla Javascript vs. jQuery?

Posted by jondavidjohn on Stack Overflow See other posts from Stack Overflow or by jondavidjohn
Published on 2011-01-10T21:53:40Z Indexed on 2011/01/10 22:53 UTC
Read the original article Hit count: 244

I have noticed while monitoring/attempting to answer common jQuery questions, that there are certain practices using javascript, instead of jQuery, that actually enable you to write less and do ... well the same amount. And may also yield performance benefits.

A specific example

$(this) vs this

Inside a click event referencing the clicked objects id

jQuery

$(this).attr("id");

Javascript

this.id;

Are there any other common practices like this? Where certain Javascript operations could be accomplished easier, without bringing jQuery into the mix. Or is this a rare case? (of a jQuery "shortcut" actually requiring more code)

EDIT : While I appreciate the answers regarding jQuery vs. plain javascript performance, I am actually looking for much more quantitative answers. While using jQuery, instances where one would actually be better off (readability/compactness) to use plain javascript instead of using $(). In addition to the example I gave in my original question.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery