Two basic questions I'm having trouble finding answers to are as follows:
1) The performance of binding a click function vs. triggering it via onclick="doingness()", as in:
$("#id").find('a').on('click',function(){
$(this).doingness();
});
versus:
<div id="id"><a onlick="doingness()"></a></div>
function doingness(){
$('#id').do();
}
It seems to me that the second one might perform best since the binding does not need to take place until the user actually clicks, so the script doesn't have to search thorugh the entire DOM to find an id and bind something to it.. is that right?
Next, I've heard that using these (whatever this is called) are very costly:
$('body').on('click', '#id', function(){
$(this).do();
});
Of course, I'm using a couple of these with dynamically loaded content so that the functions are kept alive. I'm guessing the performance hit mostly has to do with the whole function needing to be kept in memory and probably is getting reaccessed over and over to check if it should fire off again or not. Instead of this kind of code, I recently realized that I can also just add an onclick="doingness()" in the html instead, and my question is would this help performance?