Skip to content

Commit

Permalink
preconnect to 3rd party domains
Browse files Browse the repository at this point in the history
  • Loading branch information
tsubik committed Nov 19, 2024
1 parent de9eed5 commit bbb2181
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions pages/_document.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,19 @@ class MyDocument extends Document {

render() {
const { language } = this.props;
const withOsano = !!process.env.OSANO_ID;
const withGTM = !!process.env.GOOGLE_TAG_MANAGER_KEY;
const withHotjar = process.env.DISABLE_HOTJAR !== 'true' && process.env.ENV === 'production';

return (
<Html lang={language}>
<Head />
<Head>
{withOsano && <link rel="preconnect" href="https://cmp.osano.com" />}
{withGTM && <link rel="preconnect" href="https://www.googletagmanager.com" />}
{withHotjar && <link rel="preconnect" href="https://static.hotjar.com" />}
</Head>
<body>
{process.env.OSANO_ID && <Script src={`https://cmp.osano.com/${process.env.OSANO_ID}/osano.js`} strategy="afterInteractive" />}
{withOsano && <Script src={`https://cmp.osano.com/${process.env.OSANO_ID}/osano.js`} strategy="beforeInteractive" />}
<Script src={`/${language === 'en' ? '' : language + '/'}translations.js`} strategy="beforeInteractive" />
<GoogleTagManager noscript />
<Main />
Expand Down

0 comments on commit bbb2181

Please sign in to comment.