/BlogGallery

Primary LanguageTypeScript

BlogGallery

๐Ÿ“Œ Concept

  • ์ด๋ฏธ์ง€, ๊ธ€๋กœ ์ด๋ฃจ์–ด์ง„ ๋ธ”๋กœ๊ทธ

๐Ÿ”Ž Features

  • Mock Service Worker (MSW)
  • Rendering ์ตœ์ ํ™”
  • Loading ์ตœ์ ํ™”

๐Ÿค” Challenge

  • ์ด๋ฏธ์ง€ ์ตœ์ ํ™”

    • ์ด๋ฏธ์ง€ ์š”์ฒญ ์‹œ ํŒŒ๋ผ๋ฏธํ„ฐ๋กœ ํ•ด์ƒ๋„ ์กฐ์ ˆ
      • Thumbnail 120KB โ†’ 10KB
      • Main 2MB โ†’ 70KB
    • ์ด๋ฏธ์ง€ ํ”„๋ฆฌ๋กœ๋“œ
      • ๋งˆ์šฐ์Šค ์˜ค๋ฒ„๋˜๋ฉด ์ด๋ฏธ์ง€ ํ”„๋ฆฌ๋กœ๋“œ โ†’ ์‚ฌ์šฉ์ž๊ฐ€ ์ƒ์„ธํŽ˜์ด์ง€ ์ ‘๊ทผ์‹œ ๋ณด๋‹ค ๋น ๋ฅธ ๋กœ๋”ฉ์„ ์ง€์›
  • ํŠน์ • ํ•จ์ˆ˜ ๋ณ‘๋ชฉํ˜„์ƒ

    • ํ…์ŠคํŠธ์˜ ํŠน์ˆ˜๋ฌธ์ž๋ฅผ ์ œ๊ฑฐํ•˜๋Š” removeSpecialCharacter ์ตœ์ ํ™”
    • Preview์—์„œ ์“ฐ์ด๋Š” ๋‚ด์šฉ ๋ชจ๋‘๋ฅผ ํ•จ์ˆ˜์— ๋„ฃ์„ ํ•„์š”๋Š” ์—†๊ณ  ์ตœ๋Œ€ 300์ž๊นŒ์ง€๋งŒ ์ฒ˜๋ฆฌํ•˜๋ฉด ๋จ.
    • ๊ฐ€๋…์„ฑ + ํšจ์œจ์„ฑ์„ ๋†’์ด๊ธฐ์œ„ํ•ด ์ •๊ทœ์‹์œผ๋กœ ๋ณ€๊ฒฝ
  • ์ฝ”๋“œ ์Šคํ”Œ๋ฆฌํŒ…

    • cra-bundle-analyzer๋กœ View, List์— ๋ถˆํ•„์š”ํ•œ ์Šคํฌ๋ฆฝํŠธ๊ฐ€ ๋กœ๋“œ๋จ์„ ํ™•์ธํ•จ
    • suspense์™€ lazy๋ฅผ ์ด์šฉํ•ด์„œ View์™€ List๋ฅผ ๋™์ ์œผ๋กœ ์ž„ํฌํŠธ
  • ํฐํŠธ ์ตœ์ ํ™”

    • ํฐํŠธ ์‚ฌ์ด์ฆˆ ์ค„์ด๊ธฐ
      • ์›นํฐํŠธ ํฌ๋งท(woff, woff2)๋ฅผ ์ง€์›ํ•˜๋Š” ๋ธŒ๋ผ์šฐ์ €์—์„œ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋„๋ก ํ•จ
      • tff(2.1MB) โ†’ woff2(512KB)
    • ํฐํŠธ preload
      • ์ด ์‚ฌ์ดํŠธ๋Š” ๊ธ€์ด ์ค‘์š”ํ•œ ์‚ฌ์ดํŠธ์ด๋ฏ€๋กœ ํฐํŠธ๋ฅผ ๋ฏธ๋ฆฌ ๋‹ค์šด๋ฐ›๋Š” ๊ฒƒ์ด ์ค‘์š”ํ•˜๋‹ค๊ณ  ํŒ๋‹จ
        • react-app-rewired๋ฅผ ์ด์šฉํ•˜๋ฉด, CRA๋กœ ๊ตฌ์„ฑํ•œ ํ”„๋กœ์ ํŠธ์—์„œ webpack ์„ค์ • ํŒŒ์ผ์— ์ ‘๊ทผํ•˜์—ฌ ์ปค์Šคํ„ฐ๋งˆ์ด์ง•ํ•จ
        • preload-webpack-plugin๋กœ ํฐํŠธ๋ฅผ preloadํ•จ
    • ํฐํŠธ ์ ์šฉ ์‹œ์ 
      • font-display : block;์œผ๋กœ FOIT๋ฅผ ์ ์šฉํ•จ
      • ํฐํŠธ๋ฅผ ๋ฏธ๋ฆฌ ๋‹ค์šด๋กœ๋“œ ๋ฐ›๊ณ  ํฐํŠธ๊ฐ€ ์ ์šฉ๋œ ๊ธ€์„ ๋ณด์—ฌ์คŒ
  • ์ตœ์ ํ™” ๊ฒฐ๊ณผ

    Before After
    before_optimizing_1 Screenshot 2023-03-26 at 4 24 32 PM

    ๐Ÿ›  Stacks

    • React, Typescript
    • styled-components
    • MSW
    • cra-bundle-analyzer, react-app-reweird, preload-webpack-plugin