3 ms·
I don't think the assembler analogy holds with jQuery vs. JavaScript/DOM. There's a reason why an event handler has a DOM element and not a jQuery object as it
by dmethvin 14y ago
I don't think the assembler analogy holds with jQuery vs. JavaScript/DOM.
There's a reason why an event handler has a DOM element and not a jQuery object as its `this` keyword. At the time jQuery was designed, we thought everyone understood the DOM well enough to use it directly. Yes you can take the DOM element and wrap it in a jQuery object, but it's not always appropriate.
For example, `this.checked` is about 100 times faster, much prettier, and shorter to type than `$(this).is(":checked")` [1]. No amount of optimization inside jQuery will really change that performance gap.
Sometimes people get a misguided belief that every access to every JavaScript object should be through jQuery. Then we get reports that `$(window).attr("location")` don't work. [2] So yeah, learn JavaScript and the DOM.
[1] http://jsperf.com/bens-test http://jsperf.com/bens-test
[2] http://bugs.jquery.com/ticket/7607 http://bugs.jquery.com/ticket/7607