What is better from performance wise document.getElementById(\'elementId\')
or $(\'#elementId\')
?
How can I calculate the speed by myself?
Heh. Researching this question I found this excellent post. And Also a post about this with the latest into on JQuery's learning site with specific tips to optimise speed!
Worth noting that with the latest DOM specification, chances are you need not worry about performance in general. Only when you have created (or discover) a bottleneck.
Optimise Selectors
If you are concerned about performance, native getElementById is much much faster, but jQuery gives you very handy access to a lot of stuff. So, you might want to use something like :
$( document.getElementById("some_id") ).jQueryCall();
This will give you a better performance, and at the same time, allow you to use jQuery.