*:focus vs activeElement (v2)

Revision 2 of this benchmark created on


Preparation HTML

<input type="text" id="test" />

Setup

document.getElementById("test").focus();

Test runner

Ready to run.

Testing in
TestOps/sec
querySelector(*:focus)
var focussed = document.querySelector("*:focus");
ready
document.activeElement
var focussed = document.activeElement.hasFocus && document.activeElement;
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.