activeElements try..catch

Benchmark created by restrry on


Description

getting performance hit

Preparation HTML

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

Setup

function getActiveElement(){
        return document.activeElement
    }
    
    function getActiveElementSafety(){
        try {
            return document.activeElement
        } catch(e) {
            return false;
        }
    }
    
    document.getElementById("test").focus();

Test runner

Ready to run.

Testing in
TestOps/sec
getActiveElement
getActiveElement()
ready
getActiveElementSafety
getActiveElementSafety()
ready

Revisions

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

  • Revision 1: published by restrry on