From a1a00f0bfb9f7434f00d218adb66d152add82337 Mon Sep 17 00:00:00 2001 From: Jake Archibald Date: Sat, 10 Nov 2018 08:20:13 -0800 Subject: [PATCH] Preload test (#262) * Preload test * Don't prerender analytics * Version bump --- package-lock.json | 2 +- package.json | 2 +- src/index.ts | 18 ++++++++++-------- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/package-lock.json b/package-lock.json index a11b944b..5bce10cd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "squoosh", - "version": "0.1.0", + "version": "1.0.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 2179ba1f..dba7f34b 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "squoosh", - "version": "1.0.0", + "version": "1.0.1", "license": "apache-2.0", "scripts": { "start": "webpack serve --host 0.0.0.0 --hot", diff --git a/src/index.ts b/src/index.ts index a356847c..3f798cb2 100644 --- a/src/index.ts +++ b/src/index.ts @@ -13,11 +13,13 @@ if (!('customElements' in self)) { init(); } -window.ga = window.ga || ((...args) => (ga.q = ga.q || []).push(args)); -ga('create', 'UA-128752250-1', 'auto'); -ga('set', 'transport', 'beacon'); -ga('send', 'pageview'); - // Load the GA script -const s = document.createElement('script'); -s.src = 'https://www.google-analytics.com/analytics.js'; -document.head!.appendChild(s); +if (typeof PRERENDER === 'undefined') { + window.ga = window.ga || ((...args) => (ga.q = ga.q || []).push(args)); + ga('create', 'UA-128752250-1', 'auto'); + ga('set', 'transport', 'beacon'); + ga('send', 'pageview'); + // Load the GA script + const s = document.createElement('script'); + s.src = 'https://www.google-analytics.com/analytics.js'; + document.head!.appendChild(s); +}