Skip to content

Latest commit

 

History

History
19 lines (11 loc) · 757 Bytes

what_is_the_difference_between_reflow_and_repaint.md

File metadata and controls

19 lines (11 loc) · 757 Bytes

What is the difference between reflow and repaint?

Reflow is the process where the browser recalculates the layout of the page, whereas repaint only redraws elements that have changed visually, without affecting the layout.

Example:

// Reflow happens when you modify layout-affecting properties like width/height
document.body.style.width = '500px';  // Triggers reflow

// Repaint happens when you modify visual properties like background-color
document.body.style.backgroundColor = 'red';  // Triggers repaint

Tags: advanced, JavaScript, Performance