Skip to content

Make images smaller using best-in-class codecs, right in the browser.

JavaScript

Preload test (#262)

Jake Archibalda1a00f0bfb9f
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);
+}