How do I properly do object detection for window.performance.timing
?
An unknown version of Chrome being run by Googlebot is spawning the following error:
Uncaught TypeError: Cannot read property 'timing' of undefined
The only instances of window.performance.timing
are in the following snippets of code:
else if (
window.performance!=undefined
&& window.performance.timing!=undefined
&& window.performance.timing.toJSON!=undefined) {/* etc */}
Obviously regardless of my efforts to do object detection Googlebot is somehow still spawning the error message. I can not use try
and catch
and I have zero instances in my JavaScript error log of this happening in any testable (e.g. Chrome itself) browser, only Googlebot.
window.performance
isundefined
, it would not try to accesswindow.performance.timing
. The error must originate from somewhere else. - Felix Kling/* etc */
. :) The error message usually tells you the line number in your code. - Thevswindow
object? - Thevswindow.performance = undefined
... If that line is removed, the test fails - jsfiddle.net/v7zvvqoq/1 - dana