SOSO
SOSO copied to clipboard
web/css-in-js-whats-the-defference/
CSS-in-JS, 무μμ΄ λ€λ₯Έκ°μ? | SOSOLOG
Table of Contents CSS in JS? Critical CSSμ CSS-in-JS Performance Atomic CSS λ§λ¬΄λ¦¬ References CSS in JS? CSS-in-JSλ λ¨μ΄ κ·Έλλ‘ JavaScriptμ½λμμ CSSλ₯Ό μμ±νλ λ°©μμ λ§ν©λλ€. 2014λ Facebook κ°λ°μμΈ Christopher Chedeau aka Vjeux μ λ°νμμ μκ°λμμΌλ©°, κΈ°μ‘΄ CSSκ΄λ¦¬μ μ΄λ €μμ ν΄κ²°ν Facebookβ¦
μ’μ κΈ μ μ½μμ΅λλ€~!
CSS in JSμ μ°½μμκ° μ¬κΈ°μ μλ€κ³ ν΄μ μμ΅λλ€.
μ’μ κΈ κ°μ¬ν©λλ€. λ°°μκ°λλ€ :)
μ μ½μμ΅λλ€ π
μ’μκΈ κ°μ¬ν©λλ€! π
κΈ μ λ§ μ μ½μμ΅λλ€. css μ μΈλλ³ μ λ¦¬κ° μΈμκΉμλ κ² κ°μμ.
μ€νμΌμ μ μ΄ν μ μλ ννμμ§λ§, inline styleμ μ¬μ©νλ―λ‘ :before , :nth-child λ±μ pseudo selectorλ₯Ό μ¬μ©ν μ μλ λ± CSSμ λͺ¨λ specμ μ¬μ©ν μ μμ΅λλ€γ
.
μκΈ° 맨 λ§μ§λ§μ γ
κ° λ λ€μ΄κ°κ² κ°μ΅λλ·
μ’μ κΈ μ μ½μμ΅λλ€. CSS-in-JS κ° λ°μ ν΄μ¨ κ³Όμ , runtime vs zero-runtime νΉμ±μ λν΄ μ΄ν΄νλλ° λ§μ λμμ΄ λμμ΅λλ€. π
μ’μ κΈ κ°μ¬λ립λλ€! λ무 μ μ½μμ΅λλ€!
μ λ§ μ’μ κΈ κ°μ¬ν©λλ€! μ΄λ ΄νμ΄ μκ³ μλ css in jsμ λν΄ μ’ λ κΉκ² μ΄ν΄ν μ μμμ΅λλ€. π
μ’μκΈ κ°μ¬ν©λλ€ ^^ μ μ½μμ΅λλ€.
μ μ½μμ΅λλ€ κ°μ¬ν©λλ€.
μμΈν λΆμμ΄λ€μ μ’μ κΈ κ°μ¬ν©λλ€!~ zero runtime css-in-jsμ tradeoffμ λν λ΄μ©μ 보좩νλ©΄
μ₯μ : CSS νμΌμ μ μ μΌλ‘ μΆμΆνκΈ° λλ¬Έμ λ 립μ μΌλ‘ μΊμκ° κ°λ₯νκ³ , μλ°μ€ν¬λ¦½νΈ λ²λ€ μ©λμ΄ μ€μ΄λ€λ©° JSλ‘λΆν° λ 립μ μΌλ‘ CSSκ° νμ±λλ€.
λ¨μ : λ€μ΄λλ―Ή μ€νμΌλ§μ μ νμ΄ μκ³ , IE μ§μμ΄ μλλ©°, CSS νμΌμ λΆλ¬μ€κΈ° μν΄ μΆκ°μ μΈ λ€νΈμν¬ μμ²μ΄ νμνλ€. κ·Έλ¦¬κ³ SSRμ ν λ ν¬λ¦¬ν°μ»¬ CSS extractionμ΄ λΆκ°λ₯νλ―λ‘ λΆνμν μ½λλ€μ΄ λ€μ΄λ‘λ λ μ¬μ§κ° μλ€.
With static CSS extraction, the CSS is independently cachable1, your JavaScript bundle is slimmer and the CSS is parsed independently from the JavaScript.
The downsides are that it heavily limits dynamic styling, there is no IE support for dynamic styling, users have to do an extra network request to load the CSS, and it cannot do critical CSS extraction during server-side rendering, leading to (potentially lots of) unnecessary code being downloaded.
styled-component κΈ°μ¬μ λΆμ΄ μμ±νμ λκΈμμ κ°μ Έμμ΅λλ€.
μ’μ κΈ μ μ½μμ΅λλ€. κ°μ¬ν©λλ€!