Skip to content

Commit

Permalink
isom-1710 lighthouse performance preconnect to google font (#966)
Browse files Browse the repository at this point in the history
* add FontPreload

* add FontPreload to Skeleton
  • Loading branch information
adriangohjw authored Dec 29, 2024
1 parent f8d78ed commit b7f73e2
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// The following links are included to improve SEO and Lighthouse performance by optimizing font loading.
// Preconnecting to fonts.gstatic.com allows the browser to establish a connection early, reducing latency
// when fetching fonts, which can lead to faster rendering and improved user experience.

export const FontPreload = () => {
return (
<>
<link
// Establish an early connection to fonts.gstatic.com
rel="preconnect"
href="https://fonts.gstatic.com"
crossOrigin="anonymous" // required when making requests to a different origin
/>
<link
// Serve as a fallback for browsers that don't support preconnect
// at least allowing early DNS resolution
rel="dns-prefetch"
href="https://fonts.gstatic.com"
/>
</>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ export {
GoogleTagManagerBody,
} from "./GoogleTagManager"
export { BlogCard } from "./BlogCard"
export { FontPreload } from "./FontPreload"
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { IsomerPageSchemaType } from "~/engine"
import {
DatadogRum,
FontPreload,
Footer,
GoogleTagManagerBody,
GoogleTagManagerHeader,
Expand Down Expand Up @@ -33,6 +34,8 @@ export const Skeleton = ({

return (
<>
<FontPreload />

{shouldIncludeGTM && (
<GoogleTagManagerHeader
siteGtmId={site.siteGtmId}
Expand Down

0 comments on commit b7f73e2

Please sign in to comment.