Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
CSS_重構.pdf
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
CypressKuo
January 28, 2021
Technology
29
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
CSS_重構.pdf
CypressKuo
January 28, 2021
More Decks by CypressKuo
See All by CypressKuo
Deep-copying.pdf
cypresskuo
0
38
CSS_for_Web_Vitals.pdf
cypresskuo
0
42
談談_Code_review.pdf
cypresskuo
0
50
REST_vs_GraphQL_今夜はご注文はどっち.pdf
cypresskuo
0
25
跟上_JS_的腳步-ES2020.pdf
cypresskuo
0
32
Core_Web_Vitals.pdf
cypresskuo
0
57
這個時代人人都知道的敏捷開發.pdf
cypresskuo
0
63
Webassembly.pdf
cypresskuo
0
14
談談_Functional_Programming.pdf
cypresskuo
0
32
Other Decks in Technology
See All in Technology
新規事業を牽引する技術選定 〜フルスタックTypeScript開発の実践事例〜
nullnull
3
360
製造業のクラウド活用最適解〜AI,DXを加速するデータ基盤の作り方〜
hamadakoji
0
400
Rubyで音を視る
ydah
1
100
Oracle Cloud Infrastructure IaaS 新機能アップデート 2026/3 - 2026/5
oracle4engineer
PRO
1
200
生成 AI × MCP で切り拓く次世代 SRE!自律型運用への挑戦と開発者体験の進化
_awache
0
160
トークン数だけでは測れない — Claude Code 組織展開の効果検証から学んだこと
makikub
0
130
正解のないAIプロダクトをどう導くか?dodaが挑む、ユーザーの『本音』を構造化する評価設計と検証のリアル
techtekt
PRO
0
190
AWSシリコン最前線 〜AI時代のチップ選択を読み解く〜
htokoyo
1
170
チームで実践する AI-DLC 思考の軌跡を残すチェックポイント設計
belongadmin
0
2.8k
ブロックチェーン / Blockchain
ks91
PRO
0
110
ITエンジニアを取り巻く環境とキャリアパス / A career path for Japanese IT engineers
takatama
4
1.8k
探して_入れて_作って_使う_Agent_Skills___LT.pdf
peintangos
2
170
Featured
See All Featured
Designing for humans not robots
tammielis
254
26k
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
2
390
First, design no harm
axbom
PRO
2
1.2k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
55
3.4k
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
160
My Coaching Mixtape
mlcsv
0
140
For a Future-Friendly Web
brad_frost
183
10k
The B2B funnel & how to create a winning content strategy
katarinadahlin
PRO
1
380
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.5k
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
2.1k
VelocityConf: Rendering Performance Case Studies
addyosmani
333
25k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
2.9k
Transcript
CSS 重構 架構完善的樣式表
CSS Refactoring CSS重構 作者: Steve Lindstrom 譯者: 陳健文 出版社:歐萊禮 出版日期:2017/04/25
Agenda 1. 重構與架構 2. 串接 3. Good CSS 4. 正規化
5. 測試 6. 重構策略
重構與架構 重構:讓簡化程式、好複用、不改變其行為 軟體架構:描述軟體專案中,各種零件如何組織的用語
好架構 可預期 有助複用 易擴充 好維護
重構 誰需要:還活著的程式碼 誰不需要:沒有新需求、死掉的程式碼 何時:發現異味
重構與架構 簡單的說,重構能改善軟體的架構。
串接 決定樣式如何套用到元素上的方法 (其實就是 CSS 的權重
None
Good CSS 善用註解 一致的結構 (coding style) 單純的選取器 切斷 CSS 與
JS 的耦合 使用類別選取器 取有意義的名稱 避免過度模組化(? 使用對的 box model
正規化 (略 都 2021 年了,就善用別人寫好的。 把精力留在其他地方 reset.css normalize.css
測試 測試 CSS 難度高 瀏覽器多 視窗尺寸 自動化困難
測試 只測重要的瀏覽器 有彈性的設計 使用視覺回歸測試 ex: Gemini (https://github.com/gemini-testing/gemini) 遵守 Style Guide
重構策略 使用工具分析 CSS Dig (https://www.cssdig.com) 大家的好朋友: chrome dev tool
重構策略 一致性的架構規則 (coding style) 刪除廢碼 切斷 CSS 與 JS 的耦合
拆分基底樣式、拆分工具樣式 移除多餘的 ID、將 ID 轉為類別 定義可複用組件 移除行內 CSS 隔離針對性的 CSS (ex IE only or Safari only)
成效評估 沒改壞 降低耦合 減少檔案大小 省下開發時間
同場加映 OOCSS SMACSS BEM CSS Modules CSS in JS
重構過程很繁雜,但結果會讓人身心愉快,就像減肥一樣
感謝聆聽 Q & A