I’m wondering given both the native js and jquery event handler, which one should I choose for a memory consumption/performance standpoint? Say I have this html code, a simple button.
<button id="herp">derp</button>
Would
herp.onclick = function()
{
alert('hey');
}
be better than
$("#herp").click(function()
{
alert('hey');
});
?
Notwithstanding this being evil premature micro-optimisation –
jQuery wraps native events quite heavily to normalise browser compatibility issues, so will always be (slightly) slower
DOM3 style
addEventListenershould be preferred to DOM0.onxxx, but not for any performance or memory reason that I know of