Cleaner faster JavaScript, Replacing jQuery with JavaScript

Viewed 2834

Like many folks I learned JavaScript by learning jQuery.

Lately I have been replacing bits like:

$(this).attr('title') with this.title

$(this).attr('id') with this.id

$(this).val() with this.value

$(this).parent() with this.parentNode

$(this).attr('class') with this.className

Not only is my code cleaner but technically faster.

  1. Is this type of reduction acceptable and encouraged?

  2. Are there any other common practices I should be doing in raw plain JavaScript instead of jQuery?

  3. Are there any potential cross browser issues with this type of reduction-ism?

3 Answers
Related