Alex Rivera | Logout

Why doesn't querySelector('#id') map to document.getElementById('id')?

Asked 2010-11-28T19:13:02.560
10

I'm into selectors performance lately, and it's bugging me that the browsers which currently implements the Selectors API don't use document.getElementById when a simple #id is being passed.

The performance penalty is huge, so library authors continue to implement their own way around that.

Any ideas?

Edit
Report

1 Answer

0

I was comparing getElementById() and querySelector() and found that someone has already done performance comparisons and calculations.

It certainly looks as though querySelector() wins every time... and by a considerable amount.

answered 2012-06-25T08:37:44.053

Your Answer