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 Critical Path
Search
Valerio Sillari
October 13, 2017
Technology
1
35
Css Critical Path
Some info about what I got about Critical Path, and some tools and ideas how to solve it
Valerio Sillari
October 13, 2017
Tweet
Share
Other Decks in Technology
See All in Technology
ユーザーのプロフィールデータを活用した推薦精度向上の取り組み
yudai00
0
400
型システムを知りたい人のための型検査器作成入門
mame
15
3.8k
本部長の代わりに提案書レビュー! KDDI営業が毎日使うAIエージェント「A-BOSS」開発秘話
minorun365
PRO
14
1.8k
AIにどこまで任せる?実務で使える(かもしれない)AIエージェント設計の考え方
har1101
3
1.1k
脅威をモデリングしてMCPのセキュリティ対策を考えよう
flatt_security
4
1.7k
「規約、知識、オペレーション」から考える中規模以上の開発組織のCursorルールの 考え方・育て方 / Cursor Rules for Coding Styles, Domain Knowledges and Operations
yuitosato
6
1.8k
Amazon Q Developer for GitHubとAmplify Hosting でサクッとデジタル名刺を作ってみた
kmiya84377
0
3.5k
vLLM meetup Tokyo
jpishikawa
1
240
技術職じゃない私がVibe Codingで感じた、AGIが身近になる未来
blueb
0
130
研究開発部メンバーの働き⽅ / Sansan R&D Profile
sansan33
PRO
3
17k
Snowflake Intelligenceで実現できるノーコードAI活用
takumimukaiyama
1
230
「伝える」を加速させるCursor術
naomix
0
640
Featured
See All Featured
How to Ace a Technical Interview
jacobian
276
23k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.4k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
29
1.8k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
15
1.5k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
252
21k
Fashionably flexible responsive web design (full day workshop)
malarkey
407
66k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
228
22k
The Cult of Friendly URLs
andyhume
79
6.4k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
26k
YesSQL, Process and Tooling at Scale
rocio
172
14k
Code Reviewing Like a Champion
maltzj
524
40k
Unsuck your backbone
ammeep
671
58k
Transcript
CSS Critical Path by Valerio Sillari October 2017
Back to basics
How Browser Works
Browser Step for rendering/displaying a page Build DOM Build CSSOM
Render Tree Layout Paint
And CSS and JS?
How Browsers display a page Build DOM Build CSSOM Render
Tree Layout Paint Get CSS Get JS
Javascript is parser blocking When the parser finds a script
tag in the document, it blocks DOM construction (step 1), then waits for the browser to get the file and for the javascript engine to parse the script
How Browsers display a page Build DOM Build CSSOM Render
Tree Layout Paint Blocked Get CSS Get JS If we have some JS tag into the document, during the building DOM, we block the page
That’s why JS usually is at the bottom of body
You load first all the DOM, then load the js so it will not block it
BUT ...
JS is also stringly connected with CSS So it needs
also to have all the css already loaded in the CSSOM moment...
JS and CSS Build DOM Build CSSOM Render Tree Layout
Paint Blocked Get CSS Get JS JS need not only to be requested, but also parse ALL the css if exist PARSE CSS RUN JS
Solution: It doesn’t block DOM construction and don’t have the
need to wait for the CSSOM event Async scripts
How Browsers display a page Build DOM Build CSSOM Render
Tree Layout Paint Get CSS Async JS
And CSS?
For building the CSSOM (step2), the CSS parser goes through
each selector (tag, class or ID) in the CSS file and gets the styles attributed to it.
How Browsers display a page Build DOM Build CSSOM Render
Tree Layout Paint Blocked Get CSS Get JS Until we do not have ALL the css file loaded and parsed, we can not start to build the CSSOM.
CSS is render blocking The browser blocks page rendering until
it receives and processes all the css files
How Browsers display a page Build DOM Build CSSOM Render
Tree Layout Paint Blocked Get CSS Get JS Until we do not have ALL the css file loaded and parsed, we can not start to build the CSSOM.
None
CSS is the “enemy”
That’s Critical Path Css
Solutions?
Solution 01: They does not block the render of the
page! Inline styles
None
Technically, inline styles not required any css file with extra
request, and they not “block” the DOM and CSSOM
But basically impossible to maintain ...
Solution 02: Load first only basic code, then the rest
Split CSS
“Ideally, the ATF (above the fold) content should fit under
14KB — this allows the browser to paint the page after just one round trip…” https://developers.google.com/speed/docs/insights/mobile Google Page Speed
So you have 14kb to use, for delivering the DOM
+ CSS. You can split the CSS in 2 files: - The basic stuff (above the fold) - The Fanciness Stuff
Load CSS by Filament Group
Solution 03: Set inline styles with automation Inline Styles by
Task Runner
Critical by Addy Osmani
Solution 04: Not load CSS at all (until JS will
do it for you) CSS in JS
React / Angular / Vue etc... They take care of
the CSS using JS A quick example: https://vue-nuxt-test-valerio.herokuapp.com/
The Future? JS take care of the rendering of the
page. No DOM + CSS loaded at first New Css Logic
The end. Thanks. github.com/valeriosillari @stellavalerio