|
21 | 21 | - [2.3.4 이미지 lazy-load 적용](#234-이미지-lazy-load-적용)
|
22 | 22 | - [2.3.5 개선 결과](#235-개선-결과)
|
23 | 23 | - [2.4 렌더링 차단 리소스 제거하기](#24-렌더링-차단-리소스-제거하기)
|
| 24 | + - [2.4.1 defer 사용하기](#241-defer-사용하기) |
| 25 | + - [2.4.2 개선 결과](#242-개선-결과) |
| 26 | + - [2.5 기본 스레드 작업 최소화 하기](#25-기본-스레드-작업-최소화-하기) |
24 | 27 |
|
25 | 28 | ---
|
26 | 29 |
|
@@ -345,9 +348,60 @@ cookie-consent.js가 LCP와 FCP를 방해하고 있다고 설명되어 있는데
|
345 | 348 | src="//www.freeprivacypolicy.com/public/cookie-consent/4.1.0/cookie-consent.js"
|
346 | 349 | charset="UTF-8"
|
347 | 350 | ></script>
|
| 351 | + <script type="text/javascript" charset="UTF-8"> |
| 352 | + cookieconsent.run({ |
| 353 | + notice_banner_type: 'simple', |
| 354 | + consent_type: 'express', |
| 355 | + palette: 'light', |
| 356 | + language: 'en', |
| 357 | + page_load_consent_levels: ['strictly-necessary'], |
| 358 | + notice_banner_reject_button_hide: false, |
| 359 | + preferences_center_close_button_hide: false, |
| 360 | + page_refresh_confirmation_buttons: false, |
| 361 | + website_name: 'Performance Course', |
| 362 | + }); |
| 363 | + </script> |
348 | 364 | </head>
|
349 | 365 | ```
|
350 | 366 |
|
351 |
| - 해당 이슈를 해결하기 위해서는 \<head> 태그에 대한 이해가 있어야 합니다. |
| 367 | +#### 2.4.1 defer 사용하기 |
352 | 368 |
|
353 |
| - 현재 구조에서의 문제점은 |
| 369 | +해당 이슈를 해결하기 위해서는 \<head> 태그에 대한 이해가 있어야 합니다. |
| 370 | + |
| 371 | + 현재 구조에서의 문제점은 \<head>태그 안에 동기적으로 스크립트를 로딩하고있는 점입니다. 이런식으로 스크립트를 헤더안에 넣으면 해당 스크립트를 완전히 다운로드하고 실행할 떄까지 다른 HTML요소의 로드를 중단합니다. 이로인해 페이지 렌더링이 느려지며, SEO또한 부정적인 영향을 줄 수 있습니다.(크롤러가 인덱싱하기 힘듬) |
| 372 | + |
| 373 | +위 이슈를 해결하기 위해 비동기로 script를 동적 로딩하거나, body의 끝으로 이동하면 됩니다. 저는 body끝으로 이동시켜 defer를 적용하겠습니다. |
| 374 | + |
| 375 | +``` |
| 376 | +<body> |
| 377 | + <script |
| 378 | + type="text/javascript" |
| 379 | + src="//www.freeprivacypolicy.com/public/cookie-consent/4.1.0/cookie-consent.js" |
| 380 | + charset="UTF-8" |
| 381 | + defer |
| 382 | + ></script> |
| 383 | + <script type="text/javascript" charset="UTF-8" defer> |
| 384 | + cookieconsent.run({ |
| 385 | + notice_banner_type: 'simple', |
| 386 | + consent_type: 'express', |
| 387 | + palette: 'light', |
| 388 | + language: 'en', |
| 389 | + page_load_consent_levels: ['strictly-necessary'], |
| 390 | + notice_banner_reject_button_hide: false, |
| 391 | + preferences_center_close_button_hide: false, |
| 392 | + page_refresh_confirmation_buttons: false, |
| 393 | + website_name: 'Performance Course', |
| 394 | + }); |
| 395 | + </script> |
| 396 | +</body> |
| 397 | +``` |
| 398 | + |
| 399 | +--- |
| 400 | + |
| 401 | +#### 2.4.2 개선 결과 |
| 402 | + |
| 403 | +<img width="776" alt="image" src="https://github.com/user-attachments/assets/66fb09e4-13e6-4235-9376-e027d5b28081"> |
| 404 | + |
| 405 | +통과되었습니다!! |
| 406 | + |
| 407 | +### 2.5 기본 스레드 작업 최소화 하기 |
0 commit comments