Take this code snippets for example:
const div = document.querySelector('#div')
div.style.visibility = "hidden"
div.style.width = "200px"
div.style.visibility = "visible"
div {
width: 100px;
height: 100px;
background-color: gray;
}
<div id="div"></div>
The first repaint happens when setting visibility:hidden
and the second happens when setting visibility: visible
. But between these 2 repaints will setting width: 200px
cause a reflow?
In my opinion, the element setting visibility:hidden
still occupies the page space and doesn't disappear from the layout tree(render tree) so here the reflow will happen. But I'm no sure how to prove that.