1 minute read


perfomance: ์›น ์„ฑ๋Šฅ์„ ์ธก์ •.

perfomance ์ธก์ •์˜ ๊ธฐ์ค€์ด ๋˜๋Š” ํ•ญ๋ชฉ:
Eliminate render-blocking resources
Properly size images
Defer offscreen images
Minify CSS
Minify JavaScript
Remove unused CSS
Efficiently encode images
Serve images in modern formats
Enable text compression
Preconnect to required origins
Reduce server response times (TTFB)
Avoid multiple page redirects
Preload key requests
Use video formats for animated content
Reduce the impact of third-party code
Avoid non-composited animations
Lazy load third-party resources with facades


Minify CSS

CSS ํŒŒ์ผ์„ ์ถ•์†Œํ•˜์—ฌ ํŽ˜์ด์ง€ ๋กœ๋“œ ์„ฑ๋Šฅ์„ ํ–ฅ์ƒ์‹œํ‚ฌ ์ˆ˜ ์žˆ๋‹ค.

ex)

//before
h1 {
  background-color: #000000;
}
h2 {
  background-color: #000000;
}
//after
h1,
h2 {
  background-color: #000000;
}

๋˜ํ•œ ์œ„ ์˜ˆ์ œ์™€ ๊ฐ™์€ ์ƒ‰์ƒ์ฝ”๋“œ๋Š” #000000 ๋Œ€์‹  #000์œผ๋กœ ํ•œ๋ฒˆ ๋” ์ถ•์•ฝํ•ด ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค.


use video formats for animated content

ํฐ GIF ์ด๋ฏธ์ง€๋Š” ์ฝ˜ํ…์ธ ๋ฅผ ์ „๋‹ฌํ•˜๋Š” ๋ฐ ๋น„ํšจ์œจ์ ์ด๊ธฐ ๋•Œ๋ฌธ์— ๋น„๋””์˜ค๋กœ ๋ณ€ํ™˜ํ•˜๋ฉด ์‚ฌ์šฉ์ž์˜ ๋Œ€์—ญํญ์„ ํฌ๊ฒŒ ์ ˆ์•ฝํ•  ์ˆ˜ ์žˆ๋‹ค. ๋„คํŠธ์›Œํฌ ๋ฐ”์ดํŠธ๋ฅผ ์ ˆ์•ฝํ•˜๊ธฐ ์œ„ํ•ด ์• ๋‹ˆ๋ฉ”์ด์…˜์—๋Š” MPEF4/WebM ๋น„๋””์˜ค๋ฅผ ์‚ฌ์šฉํ•˜๊ณ  ์ •์  ์ด๋ฏธ์ง€์—๋Š” PNG/WebP๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์ด ์ข‹๋‹ค.

FFmpeg๋ฅผ ์‚ฌ์šฉํ•ด MPEF ๋น„๋””์˜ค ๋งŒ๋“ค๊ธฐ

FFmpeg๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ GIF my-animation.gif๋ฅผ MP4 ๋น„๋””์˜ค๋กœ ๋ณ€ํ™˜ํ•˜๋ ค๋ฉด ๋‹ค์Œ ๋ช…๋ น์„ ์‹คํ–‰ํ•˜๋ฉด ๋œ๋‹ค.

ffmpeg -i my-animation.gif my-animation.mp4

์ด๋ ‡๊ฒŒ ํ•˜๋ฉด FFmpeg๊ฐ€ ํ”Œ๋ž˜๊ทธ my-animation.gif๋กœ ํ‘œ์‹œ๋˜๋Š” ์ž…๋ ฅ -i์„ ๋ฐ›์•„ ๋น„๋””์˜ค๋ผ๋Š” ๋น„๋””์˜ค๋กœ ๋ณ€ํ™˜ํ•˜๋„๋ก ์ง€์‹œํ•œ๋‹ค. my-animation.mp4

FFmpeg๋ฅผ ์‚ฌ์šฉํ•ด WebM ๋น„๋””์˜ค ๋งŒ๋“ค๊ธฐ

WebM ๋น„๋””์˜ค๋Š” MP4 ๋น„๋””์˜ค๋ณด๋‹ค ํ›จ์”ฌ ์ž‘์ง€๋งŒ ๋ชจ๋“  ๋ธŒ๋ผ์šฐ์ €๊ฐ€ WebM์„ ์ง€์›ํ•˜๋Š” ๊ฒƒ์€ ์•„๋‹ˆ๋ฏ€๋กœ ๋‘˜ ๋‹ค ์ƒ์„ฑํ•˜๋Š” ๊ฒƒ์ด ์ข‹๋‹ค.

FFmpeg๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ my-animation.gif๋ฅผ WebM ๋น„๋””์˜ค๋กœ ๋ณ€ํ™˜ํ•˜๋ ค๋ฉด ๋‹ค์Œ ๋ช…๋ น์„ ์‹คํ–‰ํ•˜๋ฉด ๋œ๋‹ค.

ffmpeg -i my-animation.gif -c vp9 -b:v 0 -crf 41 my-animation.webm

Minify JavaScript

์‚ฌ์šฉํ•˜์ง€ ์•Š๋Š” ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ ์ฝ”๋“œ๋ฅผ ์‚ญ์ œํ•˜๊ฑฐ๋‚˜ ํ•„์ˆ˜์ ์ด ์•„๋‹Œ whitespace๋ฅผ ์—†์• ๋Š” ๊ฒƒ์€ ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ ์ฝ”๋“œ๋ฅผ ์ตœ์ ํ™” ์‹œํ‚ค๋Š”๋ฐ ๋„์›€์„ ์ค„ ์ˆ˜ ์žˆ๋‹ค. ๊ทธ๋ฆฌ๊ณ  ์ตœ์ ํ™”๋œ JavaScript์ฝ”๋“œ๋Š” ์ฝ”๋“œ๋ฅผ parseํ•˜๋Š” ์‹œ๊ฐ„๊ณผ payload์˜ ํฌ๊ธฐ๋ฅผ ์ค„์ผ ์ˆ˜ ์žˆ๋‹ค.

๋ฆฌ์•กํŠธ์˜ ๊ฒฝ์šฐ, npm run build๋กœ ์ฝ”๋“œ๊ฐ€ ์ž๋™์œผ๋กœ ์ตœ์ ํ™” ๋œ๋‹ค๋ฉด, production ๋ชจ๋“œ๋กœ ๋นŒ๋“œ๋ฅผ ํ•˜๊ณ  ์žˆ๋Š”์ง€ ๊ผญ ํ™•์ธํ•ด์•ผ ํ•œ๋‹ค.

Updated:

Leave a comment