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
36
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
GoでもGUIアプリを作りたい!
kworkdev
PRO
0
130
関係性が駆動するアジャイル──GPTに人格を与えたら、対話を通してふりかえりを習慣化できた話
mhlyc
0
140
『バイトル』CTOが語る! AIネイティブ世代と切り拓くモノづくり組織
dip_tech
PRO
1
110
AI駆動開発を推進するためにサービス開発チームで 取り組んでいること
noayaoshiro
0
250
業務効率化をさらに加速させる、ノーコードツールとStep Functionsのハイブリッド化
smt7174
2
130
"プロポーザルってなんか怖そう"という境界を超えてみた@TSUDOI by giftee Tech #1
shilo113
0
180
生成AIとM5Stack / M5 Japan Tour 2025 Autumn 東京
you
PRO
0
240
英語は話せません!それでも海外チームと信頼関係を作るため、対話を重ねた2ヶ月間のまなび
niioka_97
0
130
from Sakichi Toyoda to Agile
kawaguti
PRO
1
110
リセラー企業のテクサポ担当が考える、生成 AI 時代のトラブルシュート 2025
kazzpapa3
1
150
自動テストのコストと向き合ってみた
qa
0
220
後進育成のしくじり〜任せるスキルとリーダーシップの両立〜
matsu0228
7
3.2k
Featured
See All Featured
Embracing the Ebb and Flow
colly
88
4.8k
Java REST API Framework Comparison - PWX 2021
mraible
33
8.9k
How To Stay Up To Date on Web Technology
chriscoyier
791
250k
Build The Right Thing And Hit Your Dates
maggiecrowley
37
2.9k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
53k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.5k
What's in a price? How to price your products and services
michaelherold
246
12k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
The Cost Of JavaScript in 2023
addyosmani
54
9k
Building Applications with DynamoDB
mza
96
6.7k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
16k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
19
1.2k
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