Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
reflow/repaint
Search
Yuta Hiroto
November 10, 2016
Technology
210
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
reflow/repaint
11/11の社内勉強会資料
Yuta Hiroto
November 10, 2016
More Decks by Yuta Hiroto
See All by Yuta Hiroto
Node8.3.0について
abouthiroppy
1
3.2k
ECMAScript
abouthiroppy
0
710
my tools
abouthiroppy
0
180
OSSを楽しむ話
abouthiroppy
0
200
React Nativeを触ってみた話
abouthiroppy
0
190
Other Decks in Technology
See All in Technology
技術的負債から考える、AI時代のエンジニアリング投資 — ビズリーチの技術的負債と向き合った経験から、変更し続けられるソフトウェアを考える/ technical-debt-con2026
visional_engineering_and_design
4
3.7k
ADKで始める業務改善 - AIエージェント開発時の考えと設計
harappa80
2
290
10年欲しかった音楽管理アプリを、AIと一緒に作りはじめた
judau
1
110
特殊変数大全
dak2
0
130
2026-09-08 そのJavaモダナイゼーション、AIに丸投げで大丈夫?IBM Bobで変わる品質と効率
yutanonaka
1
190
Harness Engineering on Rails
joelq
0
470
負債のメタファと2026年 / Debt Metaphor in Agentic Engineering Age 202609 Edition
twada
PRO
12
6.7k
現場で役立つ技術負債の効果的な返済方法
masuda220
PRO
11
5.2k
AI感のないAWS構成図をAIエージェントに描かせたい!
sagochiko
1
340
Oracle Cloud Infrastructure(OCI):Onboarding Session(はじめてのOCI/Oracle Supportご利⽤ガイド)
oracle4engineer
PRO
2
20k
【ゲームメーカーズスクランブル2026】『Shadowverse: Worlds Beyond』UIとアニメーションで実現する最高のユーザー体験を叶えるプロトタイピング
cygames
PRO
1
360
高負荷プロダクション環境におけるAWS Lambdaのリアル 〜スケールとコストを左右する実行ライフサイクルの技術仕様〜
maimyyym
2
550
Featured
See All Featured
Docker and Python
trallard
47
4.2k
Everyday Curiosity
cassininazir
0
330
Done Done
chrislema
187
17k
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
590
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
1
770
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.5k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
10k
How STYLIGHT went responsive
nonsquared
100
6.3k
The browser strikes back
jonoalderson
0
1.7k
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
67
58k
The Spectacular Lies of Maps
axbom
PRO
1
1k
HTML-Aware ERB: The Path to Reactive Rendering @ RubyCon 2026, Rimini, Italy
marcoroth
5
740
Transcript
Reflow / Repaint Yuta Hiroto @about_hiroppy #frontier-js-2
Reflow / Repaint ؾʹ͔͚ͯ·͔͢ʁ
ͳͥؾʹ͢Δඞཁ͋Δͷʁ ෛՙ͕େ͖͘ɺύϑΥʔϚϯεʹ Өڹ͕͋Δ͔Β UXͷԼ
ϒϥβͷඳըϓϩηε DOM Tree Style Rules HTML CSS Render Tree Layout
Paint Display Webkitͷ؆ུϑϩʔ
ϒϥβͷඳըϓϩηε DOM Tree Style Rules HTML CSS Render Tree Display
Layout ࠓ͢ͷ͜͜ Paint
Layout(Reflow) • GekkoͰReflow, WebkitͰLayoutͱݺΕ·͢ • ϨϯμʔπϦʔ͕࠶ධՁ͞Ε࠶ܭࢉ͢ΔॴͰ͢ • ཁૉʹḪͬͯ࠶ܭࢉ͢ΔͨΊɺύϑΥʔϚϯεʹ Өڹ͕ग़͍͢ ࠓճReflowͱݺͼਐΊ·͢
Paint • LayoutΑΓ͍͕ɺΓෛՙ͕ߴ͍ • Repaintͱ࠶ܭࢉ͞ΕͨϨϯμʔπϦʔͷ݁ՌΛݩʹ εΫϦʔϯΛߋ৽͢Δ͜ͱΛݴ͍·͢ • GPUϨϯμϦϯάΛ͏͜ͱʹΑΓɺൃੜΛ͑Δ͜ͱ͕Մೳ ΞχϝʔγϣϯͰtransform, opacityͳͲΛ༻͢Δ
• ҎԼͷϓϩύςΟ͕ओʹෛՙ͕ߴ͍ྫͰ͢ - box-shadow - border-radius - background - filter: blur - gradient - position:fixed
Reflow / Repaint Reflow Repaint ϨϯμʔπϦʔ͕࣋ͭ DOMཁૉΛ࠶ܭࢉ͢Δ εΫϦʔϯͷ ࠶ඳըॲཧΛ͢Δ
ൃੜτϦΨʔ ReFlow + RePaint RePaintͷΈ DOM NodeͷՃɾߋ৽ɾআ windowͷαΠζมߋɾεΫϩʔϧ ϑΥϯταΠζͷมߋ Ξχϝʔγϣϯ
ελΠϧଐੑͷՃɾมߋɾআ ίϯςΩετͷมߋ offsetWidth, offsetHeightͷ࠶ܭࢉ cssٖࣅΫϥεͷૢ࡞ css#color css#outline css#visibility: hidden css#backgroundColor
const style = document.body.style; // reflow + repaint style.border =
'1px solid #333'; style.padding = '10px'; style.fontSize = '1px'; document.body.appendChild(document.createTextNode('hoge!')); // repaint style.color = 'blue'; style.backgroundColor = '#0ff';
ൃੜΛ࠷খݶʹ͑Δ • styleͰͷมߋΛආ͚Δ • documentFragmentΛ͏
styleͰͷมߋΛආ͚Δ • DOMͷมߋճΛ1ճʹ ·ͱΊΔ • display: noneͰӅ͠มߋ(n ճ)ͤ͞displayΛ͢ (nճ ͷreflow/repaintʹର͠ɺ
͜ͷํ๏ͩͱ2ճͰࡁΉ) // js const el = document.body; const style = el.style; // bad style.left = '10px'; // reflow, repaint style.top = '20px'; // reflow, repaint // good el.classList.add("anotherclass"); // reflow, repaint // .css .anotherclass { left: 10px; top: 20px; }
ϒϥβͷΈ • ReFlow/RePaintෛՙ͕ߴ͍ͨΊɺ ϒϥβࣗମ͕࠷దԽΛߦ͍·͢ • ϒϥβJavaScript͔ΒͷstyleมߋΛΩϡʔʹ٧Ίɺ·ͱΊͯ ࠷ޙʹॲཧΛߦ͏͜ͱʹΑΓReflow/RepaintΛ࠷খݶʹ͑·͢ function updateBodyStyle() {
const style = document.body.style; style.top = '50px'; style.left = '30px'; style.right = '40px'; style.bottom = '20px'; } 4ճมߋΛߦ͍ͬͯΔ͕ Reflow/Repaint1ճ͔͠ൃੜ͠ͳ͍
ReFlowͷ࠷దԽΛյ͢ • ϒϥβstyleΛΩϡʔʹ٧ΊɺҰఆ࣌ؒܦ͔ͭมߋճͰΩϡʔΛ ϑϥογϡ͠·͢ • ҎԼͷελΠϧΛಡΈࠐΉͱڧ੍తʹϑϥογϡ͢Δ͜ͱ͕ՄೳͰ͢ - offsetTop/Left/Width/Height - scrollTop/Left/Width/Height
- clientTop/Left/Width/Height - getComputedStyle() - getClientRect() - scrollBy(), scrollTo() - scrollX, scrollY - height, width const div = document.querySelector('div'); for (let i = 0; i < 100; i++) { div.style.left = div.offsetLeft + 50 + 'px'; } ѱ͍ྫ ϧʔϓ֎ͰΩϟογϡ͢Δ͖
documentFragmentΛ͏ • documentFragmentΛ͍ɺෳͷมߋΛ ·ͱΊϨϯμʔπϦʔʹՃ͢Δ͜ͱʹΑΓ ReflowΛҰճʹ͑·͢ https://developer.mozilla.org/en-US/docs/Web/API/DocumentFragment
chromeͰ֬ೝ͢Δํ๏ Rendering Timeline/Paint Profiler
·ͱΊ • ReFlowͱRePaintͷଟൃΛؾʹ͢ΔΑ͏ʹ͠Α͏ • ൃੜτϦΨʔʹͳΔJavaScriptʹؾΛ͚ͭΑ͏ • ΞχϝʔγϣϯCSS transformΛ͓͏
ࢀߟจݙ • https://www.html5rocks.com/ja/tutorials/ internals/howbrowserswork/ • http://rochas.cc/blog/2013/12/09/ frontrend.html • https://gist.github.com/paulirish/ 5d52fb081b3570c81e3a