-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgatsby-browser.js
33 lines (28 loc) · 1 KB
/
gatsby-browser.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
"use strict";
exports.__esModule = true;
exports.onInitialClientRender = void 0;
const onInitialClientRender = (_, pluginOptions) => {
const hotjarId = pluginOptions.id;
const hotjarSv = pluginOptions.sv;
const delayLoad = pluginOptions.optimize;
const script = document.createElement("script");
script.innerHTML = ` (function(h,o,t,j,a,r){
h.hj=h.hj||function(){(h.hj.q=h.hj.q||[]).push(arguments)};
h._hjSettings={hjid:${hotjarId},hjsv:${hotjarSv}};
a=o.getElementsByTagName('head')[0];
r=o.createElement('script');r.async=1;
r.src=t+h._hjSettings.hjid+j+h._hjSettings.hjsv;
a.appendChild(r);
})(window,document,'https://static.hotjar.com/c/hotjar-','.js?sv=')`;
const appendScript = () => {
document.body.appendChild(script);
};
if (!delayLoad) {
appendScript();
} else {
setTimeout(() => {
window["requestIdleCallback"] ? window.requestIdleCallback(appendScript) : appendScript();
}, 3000);
}
};
exports.onInitialClientRender = onInitialClientRender;