@@ -17,14 +17,25 @@ export const metadata: Metadata = {
1717
1818const inter = Inter ( {
1919 subsets : [ "latin" ] ,
20- display : "swap" ,
20+ display : "swap" , // FOUT 방지
21+ preload : true ,
2122} ) ;
2223
2324const pretendard = localFont ( {
2425 src : "../../public/fonts/PretendardVariable.woff2" ,
25- display : "swap" ,
26+ display : "swap" , // FOUT 방지를 위한 swap 설정
2627 weight : "45 920" ,
2728 variable : "--font-pretendard" ,
29+ preload : true , // 폰트 우선 로딩
30+ } ) ;
31+
32+ const KakaoScriptLoader = dynamic ( ( ) => import ( "@/lib/ScriptLoader/KakaoScriptLoader" ) , {
33+ ssr : false ,
34+ loading : ( ) => null ,
35+ } ) ;
36+ const AppleScriptLoader = dynamic ( ( ) => import ( "@/lib/ScriptLoader/AppleScriptLoader" ) , {
37+ ssr : false ,
38+ loading : ( ) => null ,
2839} ) ;
2940
3041const KakaoScriptLoader = dynamic ( ( ) => import ( "@/lib/ScriptLoader/KakaoScriptLoader" ) , {
@@ -54,23 +65,38 @@ const RootLayout = ({ children }: { children: React.ReactNode }) => (
5465 < AlertProvider >
5566 < html lang = "ko" >
5667 < head >
57- < link rel = " preload" href = "/_next/static/css/globals.css" as = "style" />
68+ { /* Critical 폰트 preload with high priority */ }
5869 < link
59- rel = "stylesheet"
60- href = "/_next/static/css/globals.css"
61- media = "print"
62- onLoad = { ( e ) => {
63- ( e . currentTarget as HTMLLinkElement ) . media = "all" ;
70+ rel = "preload"
71+ href = "/fonts/PretendardVariable.woff2"
72+ as = "font"
73+ type = "font/woff2"
74+ crossOrigin = "anonymous"
75+ />
76+ { /* Prevent layout shift with font-display: swap */ }
77+ < style
78+ dangerouslySetInnerHTML = { {
79+ __html : `
80+ @font-face {
81+ font-family: 'Pretendard';
82+ src: url('/fonts/PretendardVariable.woff2') format('woff2');
83+ font-weight: 45 920;
84+ font-display: swap;
85+ font-style: normal;
86+ }
87+ ` ,
6488 } }
6589 />
66- < noscript >
67- < link rel = "stylesheet" href = "/_next/static/css/globals.css" />
68- </ noscript >
90+ { /* DNS prefetch for external resources */ }
91+ < link rel = "dns-prefetch" href = "//www.googletagmanager.com" />
92+ < link rel = "dns-prefetch" href = "//connect.facebook.net" />
93+ < link rel = "dns-prefetch" href = "//t1.kakaocdn.net" />
6994 </ head >
70- < KakaoScriptLoader />
71- < AppleScriptLoader />
72- < GoogleAnalytics gaId = "G-V1KLYZC1DS" />
95+
7396 < body className = { `${ pretendard . className } ${ inter . className } ` } >
97+ < KakaoScriptLoader />
98+ < AppleScriptLoader />
99+ < GoogleAnalytics gaId = "G-V1KLYZC1DS" />
74100 < QueryProvider >
75101 < GlobalLayout > { children } </ GlobalLayout >
76102 </ QueryProvider >
0 commit comments