 <p>What if <code>window.performance</code> is <code>null</code>? I bet you would get the same error message.</p> <p>That's why the canonical way to check objects existence is:</p> <p><code>if (window.performance &amp;&amp; window.performance.whatever &amp;&amp; ...) ...</code></p>