From c4b21bf5ce856e42429f78ea4d6124a3674f7d94 Mon Sep 17 00:00:00 2001 From: Julien Blatecky Date: Sun, 29 Jul 2018 09:35:46 +0200 Subject: [PATCH] Scoping js variables to avoid polluting global scope --- src/gatsby-ssr.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/gatsby-ssr.js b/src/gatsby-ssr.js index ddf8817..4191fab 100644 --- a/src/gatsby-ssr.js +++ b/src/gatsby-ssr.js @@ -16,8 +16,10 @@ function buildTrackingCode(pluginOptions) { window._paq.push(['enableHeartBeatTimer']); window.start = new Date(); - var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; - g.defer=true; g.async=true; g.src='${script}'; s.parentNode.insertBefore(g,s); + (function() { + var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; + g.type='text/javascript'; g.async=true; g.defer=true; g.src='${script}'; s.parentNode.insertBefore(g,s); + })(); if (window.dev === true) { console.log('[Matomo] Tracking initialized')