Skip to content

Commit 2626517

Browse files
authored
Merge pull request #13120 from ethereum/performance-lazy-load-feedback-widget
performance: lazy load FeedbackWidget component
2 parents d70c495 + 541ce69 commit 2626517

File tree

1 file changed

+34
-32
lines changed

1 file changed

+34
-32
lines changed

src/layouts/RootLayout.tsx

Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,52 @@
1-
import { join } from "path"
1+
// import { join } from "path"
22

3-
import { useRouter } from "next/router"
3+
import dynamic from "next/dynamic"
4+
// import { useRouter } from "next/router"
45
import { Container } from "@chakra-ui/react"
56

67
import type { Root } from "@/lib/types"
78

8-
import FeedbackWidget from "@/components/FeedbackWidget"
99
import Footer from "@/components/Footer"
1010
import Nav from "@/components/Nav"
1111
import { SkipLink } from "@/components/SkipLink"
12-
import TranslationBanner from "@/components/TranslationBanner"
13-
import TranslationBannerLegal from "@/components/TranslationBannerLegal"
14-
15-
import { toPosixPath } from "@/lib/utils/relativePath"
16-
17-
import { DEFAULT_LOCALE } from "@/lib/constants"
1812

13+
// import TranslationBanner from "@/components/TranslationBanner"
14+
// import TranslationBannerLegal from "@/components/TranslationBannerLegal"
15+
// import { toPosixPath } from "@/lib/utils/relativePath"
16+
// import { DEFAULT_LOCALE } from "@/lib/constants"
1917
import { lightTheme as oldTheme } from "../theme"
2018

19+
const FeedbackWidget = dynamic(() => import("@/components/FeedbackWidget"), {
20+
ssr: false,
21+
})
22+
2123
export const RootLayout = ({
2224
children,
23-
contentIsOutdated,
24-
contentNotTranslated,
25+
// contentIsOutdated,
26+
// contentNotTranslated,
2527
lastDeployDate,
2628
}: Root) => {
27-
const { locale, asPath } = useRouter()
28-
29-
const CONTRIBUTING = "/contributing/"
30-
const isUntranslatedContributingPage =
31-
asPath.includes(CONTRIBUTING) &&
32-
!(asPath.endsWith(CONTRIBUTING) || asPath.includes("/translation-program/"))
33-
34-
const isLegal =
35-
isUntranslatedContributingPage ||
36-
asPath.includes(`/cookie-policy/`) ||
37-
asPath.includes(`/privacy-policy/`) ||
38-
asPath.includes(`/terms-of-use/`) ||
39-
asPath.includes(`/style-guide/`)
40-
41-
const isPageLanguageEnglish = locale === DEFAULT_LOCALE
42-
43-
const shouldShowTranslationBanner =
44-
(contentIsOutdated || (contentNotTranslated && !isPageLanguageEnglish)) &&
45-
!isLegal
46-
const shouldShowLegalTranslationBanner = isLegal && !isPageLanguageEnglish
47-
const originalPagePath = toPosixPath(join(DEFAULT_LOCALE, asPath))
29+
// const { locale, asPath } = useRouter()
30+
31+
// const CONTRIBUTING = "/contributing/"
32+
// const isUntranslatedContributingPage =
33+
// asPath.includes(CONTRIBUTING) &&
34+
// !(asPath.endsWith(CONTRIBUTING) || asPath.includes("/translation-program/"))
35+
36+
// const isLegal =
37+
// isUntranslatedContributingPage ||
38+
// asPath.includes(`/cookie-policy/`) ||
39+
// asPath.includes(`/privacy-policy/`) ||
40+
// asPath.includes(`/terms-of-use/`) ||
41+
// asPath.includes(`/style-guide/`)
42+
43+
// const isPageLanguageEnglish = locale === DEFAULT_LOCALE
44+
45+
// const shouldShowTranslationBanner =
46+
// (contentIsOutdated || (contentNotTranslated && !isPageLanguageEnglish)) &&
47+
// !isLegal
48+
// const shouldShowLegalTranslationBanner = isLegal && !isPageLanguageEnglish
49+
// const originalPagePath = toPosixPath(join(DEFAULT_LOCALE, asPath))
4850

4951
return (
5052
<Container mx="auto" maxW={oldTheme.variables.maxPageWidth}>

0 commit comments

Comments
 (0)