Skip to content

Commit

Permalink
catch error of ecoindex undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
hrenaud (NovaGaïa) committed Mar 28, 2022
1 parent cf23f00 commit e2f8734
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/gatsby-browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ exports.onRouteUpdate = pluginOptions => {
load_js()
function calculateECOIndex() {
setTimeout(function () {
if (ecoindex !== undefined) {
try {
const e = document.getElementsByTagName('*').length,
n = window.performance.getEntriesByType('resource')
n.push({
Expand All @@ -28,6 +28,8 @@ exports.onRouteUpdate = pluginOptions => {
window.performance.getEntriesByType('navigation')[0].transferSize,
}),
ecoindex(e, n)
} catch (error) {
// console.log(error);
}
}, 1e3)
}
Expand Down

0 comments on commit e2f8734

Please sign in to comment.