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

JS Bundle Size 분석 후 개선 #49

Closed
BoBeenLee opened this issue Jul 22, 2022 · 4 comments
Closed

JS Bundle Size 분석 후 개선 #49

BoBeenLee opened this issue Jul 22, 2022 · 4 comments

Comments

@BoBeenLee
Copy link
Owner

BoBeenLee commented Jul 22, 2022

Description

Webpack Bundle Analyzer로 분석

Screen Shot 2022-07-23 at 2 07 27 PM

lodash 번들 최적화

AS-IS Lodash

Screen Shot 2022-07-23 at 1 24 04 PM

TO-BE Lodash 제거

Screen Shot 2022-07-23 at 2 05 47 PM

moment 번들 최적화

import dateFnsParse from 'date-fns/parse';
import dateFnsFormat from 'date-fns/format';
import ko from 'date-fns/locale/ko';
import enUS from 'date-fns/locale/en-US';

react-icons 번들 최적화

AS-IS

Screen Shot 2022-07-23 at 2 37 31 PM

TO-BE

  • 대략 1mb에서 10kb로 줄일 수 있었음. 꽤나 의미있는 차이

Screen Shot 2022-07-23 at 4 39 13 PM

사용하지 않는 이미지 번들링 제거

Screen Shot 2022-07-23 at 2 28 50 PM

- 차지하는 사이즈가 크지 않기에 나중에 따로 작업하기

PR 생성시 번들 사이즈 체크 로직 추가 (얼마나 개선되었는지 보기 위함)

효과

  • 개발자 경험으론 빌드 타임을 줄일 수 있음
  • 사용자 경험으론 js로드 시간을 줄여 모바일, wifi가 취약한 환경(ex) 3g)에서도 좀더 빠른 로드를 제공해줄 수 있음
    • wifi가 좋은 환경에서는 체감이 힘들 수 있음

Reference

@BoBeenLee
Copy link
Owner Author

lodash 번들 최적화 vs https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore#_chunk

  • 후자에 익숙해지는게 번들 최적화면, lodash 최적화를 고려하지 않아도 되는 부분들이 존재하기에 이점이 있는듯합니다.

@BoBeenLee
Copy link
Owner Author

@BoBeenLee
Copy link
Owner Author

lodash 번들링 최적화 부분 중...

you don't need lodash 부분에서 모든 구현체가 없기에 https://www.npmjs.com/package/lodash.isequal 와 같이 사용하는 부분만 최소화하여 dep을 유지하는게 중요한듯 싶다.

@BoBeenLee
Copy link
Owner Author

bundle CI - https://web.dev/monitor-and-analyze/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant