Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore-fe: Pretendard 웹폰트 로드 최적화 적용 #691

Merged
merged 3 commits into from
Sep 24, 2024

Conversation

github-actions[bot]
Copy link
Contributor

@github-actions github-actions bot commented Sep 23, 2024

Original issue description

목적

  • 현재 크루루의 웹 서비스는 어떠한 이용 환경에서든 통일성 있는 비주얼을 보여주기 위해 Pretendard 웹폰트를 사용하고 있습니다.
  • 그러나 웹폰트의 개별 전송 용량이 비대하며(개당 약 1.2MB), 로드 타이밍 또한 늦는 편입니다.
  • 이로 인해 네트워크 환경이 좋지 못한 환경에서는 사용자 경험에 아래와 같은 악영향이 생길 수 있어요.
    • 크루루 서비스 로딩 지연
    • 웹폰트의 뒤늦은 로딩으로 인한 FOUT(Flash of Unstyled Text) 현상 심화
  • 웹폰트의 로드 용량을 줄이고, 리소스 로드 타이밍을 조정하여 위의 문제들을 최소화합니다.

작업 세부사항

  • 웹폰트 최적화 방안 적용 (가변 다이나믹 서브셋 적용)
  • 웹폰트에 대한 preconnect, onload 적용

참고 자료

  • 현재 웹폰트 로딩 용량
    image
  • 웹폰트별 전송 타이밍
    크루루 웹폰트 전송 타이밍

아래의 별표줄 밑에 요구사항 ID만 작성해주세요. Prefix 금지!


FONT_FIX_01

목적

  • 웹폰트의 로드 용량과 타이밍을 줄여서, 기존에 존재했던 아래 문제들을 최소화합니다.
    • 크루루 서비스 로딩 지연
    • 웹폰트의 뒤늦은 로딩으로 인한 FOUT(Flash of Unstyled Text) 현상 심화

작업 세부사항

  • 웹폰트 최적화 방안 적용 (가변 다이나믹 서브셋 적용)
  • 웹폰트 CDN 경로에 대한 preconnect, 웹폰트 CSS 리소스에 대한 preload 적용

작업 전후 비교

  • 아레 작업은 모두 Google Chrome, Fast 4G 네트워크 환경 기준으로 진행되었어요.

개별 폰트 전송 속도

  • 기존에는 웹폰트 하나를 다운로드 받는 데에 무려 5.99초가 소요되었습니다.
    웹폰트 최적화 이전

  • 개선 이후에는 웹폰트 서브셋 하나당 다운로드가 0.45초 이내에 이루어지고 있습니다.
    웹폰트 최적화 이후

전체 웹폰트 전송량

  • 기존에는 랜딩 페이지 기준으로 웹폰트로만 약 4.7MB를 다운로드 받아야 했습니다.
    웹폰트 최적화 이전 다운로드

  • 개선 이후에는 랜딩 페이지에서 262KB만 다운로드 되는 것을 확인하실 수 있습니다.
    웹폰트 최적화 이후 다운로드

관련 이슈

@github-actions github-actions bot added chore 빌드 업무 수정, 패키지 관리자 구성 등 업데이트, Production Code 변경 없음 frontend 프론트엔드 labels Sep 23, 2024
@github-actions github-actions bot added this to the 스프린트 5.0 milestone Sep 23, 2024
Copy link
Contributor Author

1727080948.837039

Copy link
Contributor Author

1727080957.390739

Copy link
Contributor

@lurgi lurgi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

코드는 몇 줄 없지만 핵심적인 부분 이라 생각합니다!! 정말 고생하셨어요~!!!~~!

Comment on lines -15 to -21
@font-face {
font-family: 'Pretendard';
src: url('https://fastly.jsdelivr.net/gh/Project-Noonnu/[email protected]/Pretendard-${name}.woff')
format('woff');
font-weight: ${weight};
font-style: normal;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

font-face를 왜, 언제 써야하지? 궁금해서 찾아보니, 자체적으로 글꼴을 만들어서 사용하는 회사의 경우 (로컬 서버를 사용하는 경우) 커스텀하기 용이하다고 하네용~!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오 저도 사실 궁금했던 내용인데 짚어주셔서 감사해요! 좋은 노하우를 알아갑니다 🙏

Comment on lines +9 to +15
<link
rel="preload"
as="style"
href="https://cdn.jsdelivr.net/gh/orioncactus/[email protected]/dist/web/variable/pretendardvariable-dynamic-subset.min.css"
onload="this.onload=null;this.rel='stylesheet'"
crossorigin
/>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

onload까지 꼼꼼하게..! 👍

Comment on lines +4 to +8
<link
rel="preconnect"
href="https://cdn.jsdelivr.net"
crossorigin="anonymous"
/>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

preload를 해주는데 preconnect를 해주는게 궁금해서 찾아봤어요!
이미 아시겠지만 preload의 네트워크 요청 이전 preconnect가 실행되어 성능개선에 도움이 된다고 하네용!👍

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

맞습니다! 우리 프로젝트처럼 외부 CDN으로부터 리소스를 많이 받아와야 할 때 preconnect를 쓰면 TLS 핸드셰이크와 TLS 연결 시간을 줄일 수 있다고 하네요. :)

Copy link
Contributor

@llqqssttyy llqqssttyy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

덕분에 가변체라는 개념을 처음 알았습니다! 자료 조사하시느라 고생 많으셨어요. 어푸르브 드립니다~

<link
rel="preload"
as="style"
href="https://cdn.jsdelivr.net/gh/orioncactus/[email protected]/dist/web/variable/pretendardvariable-dynamic-subset.min.css"
Copy link
Contributor

@llqqssttyy llqqssttyy Sep 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아르 덕분에 가변체에 대해 알았네요!
직관적으로 모든 폰트의 굵기를 담고 있는 서체라면 오히려 더 용량이 무거운 건 아닌가 하는 의문이 들었는데, 개별 파일보단 약간 무거울 수 있지만 다른 굵기의 파일을 여러 개 가져오는 것 보다 훨씬 가볍군요👀

Traditionally, all possible weights and styles have been separated out into different font files, whereas variable fonts combine all of those variations into one. Because of this, overall file size is greatly reduced compared to loading multiple individual font files—and that’s a key consideration for web typography.

100단위의 정해진 수가 아닌 그 사이의 수를 마음대로 조절할 수 있다는 점도 재밌는 포인트네요.ㅎㅎ

@seongjinme seongjinme merged commit dcae8f5 into fe/develop Sep 24, 2024
38 checks passed
@seongjinme seongjinme deleted the fe-690-FONT_FIX_01 branch September 24, 2024 01:27
llqqssttyy pushed a commit that referenced this pull request Sep 27, 2024
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Seongjin Hong <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore 빌드 업무 수정, 패키지 관리자 구성 등 업데이트, Production Code 변경 없음 frontend 프론트엔드
Projects
Status: 완료
Development

Successfully merging this pull request may close these issues.

3 participants