jquery, performance-wise what is faster getElementById or jquery selector?

javascript, jquery, jquery-selectors

Solution

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.

Problem

What is better from performance wise `document.getElementById('elementId')` or `$('#elementId')` ? How can I calculate the speed by myself?

Original source