diff --git a/docusaurus.config.ts b/docusaurus.config.ts index da14145d8..924d89e6c 100644 --- a/docusaurus.config.ts +++ b/docusaurus.config.ts @@ -13,6 +13,30 @@ export default { trailingSlash: true, tagline: "GraphQL platform engineered for scale", headTags: [ + { + tagName: "link", + attributes: { + rel: "preconnect", + href: "https://fonts.googleapis.com", + }, + }, + { + tagName: "link", + attributes: { + rel: "preconnect", + href: "https://fonts.gstatic.com", + crossorigin: "anonymous", + }, + }, + { + tagName: "link", + attributes: { + rel: "preload", + as: "style", + href: "https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;700&family=Space+Mono&display=swap", + onload: "this.onload=null;this.rel='stylesheet'", + }, + }, { tagName: "script", attributes: { @@ -20,6 +44,8 @@ export default { "data-accountid": "CZPG9aVdtk59Tjz4SMTu8w==", "data-websiteid": "75VGI0NlBqessD4BQn2pFg==", src: "https://app.robofy.ai/bot/js/common.js?v=" + new Date().getTime(), + async: "true", + defer: "true", }, }, { diff --git a/src/components/home/Banner.tsx b/src/components/home/Banner.tsx index 50c3ea681..26d6a9617 100644 --- a/src/components/home/Banner.tsx +++ b/src/components/home/Banner.tsx @@ -2,7 +2,6 @@ import React from "react" import Heading from "@theme/Heading" import LinkButton from "../shared/LinkButton" -import HeroImage from "@site/static/images/home/hero.svg" import {analyticsHandler} from "@site/src/utils" import {Theme, codeSandboxUrl} from "@site/src/constants" import {pageLinks} from "@site/src/constants/routes" @@ -59,7 +58,13 @@ const Banner = (): JSX.Element => { - + Tailcall GraphQL platform workflow ) } diff --git a/src/components/home/LazyHomeSection.tsx b/src/components/home/LazyHomeSection.tsx new file mode 100644 index 000000000..94a2b47d7 --- /dev/null +++ b/src/components/home/LazyHomeSection.tsx @@ -0,0 +1,44 @@ +import React, {useEffect, useRef, useState} from "react" + +interface LazyHomeSectionProps { + children: React.ReactNode + minHeight?: number +} + +const LazyHomeSection: React.FC = ({children, minHeight = 320}) => { + const containerRef = useRef(null) + const [isVisible, setIsVisible] = useState(false) + + useEffect(() => { + const container = containerRef.current + if (!container || isVisible) { + return + } + + if (!("IntersectionObserver" in window)) { + setIsVisible(true) + return + } + + const observer = new IntersectionObserver( + ([entry]) => { + if (entry.isIntersecting) { + setIsVisible(true) + observer.disconnect() + } + }, + {rootMargin: "600px 0px"} + ) + + observer.observe(container) + return () => observer.disconnect() + }, [isVisible]) + + return ( +
+ {isVisible ? children : null} +
+ ) +} + +export default LazyHomeSection diff --git a/src/components/home/index.tsx b/src/components/home/index.tsx index 0a8a67dbc..d00300eb2 100644 --- a/src/components/home/index.tsx +++ b/src/components/home/index.tsx @@ -8,17 +8,30 @@ import Configuration from "./Configuration" import Testimonials from "./Testimonials" import Announcement from "../shared/Announcement" import IntroductionVideo from "./IntroductionVideo" +import LazyHomeSection from "./LazyHomeSection" const HomePage = (): JSX.Element => { return (
- - - - - + + + + + + + + + + + + + + + {/* */} - + + +
) } diff --git a/src/css/custom.css b/src/css/custom.css index 0e37d054a..795d812ca 100644 --- a/src/css/custom.css +++ b/src/css/custom.css @@ -1,5 +1,3 @@ -@import url("https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;700&family=Space+Mono&display=swap"); - @tailwind base; @tailwind components; @tailwind utilities;