How does a browser render a webpage?
There are 6 general steps in this process:
Construct DOM tree
: a tree of nodes corresponding toHTML
elementsConstruct CSSOM tree
: a tree of nodes corresponding toCSS
selectorsConstruct Render tree
: The browser traverses the DOM tree and matches every element with the appropriate style from theCSSOM
tree.Layout phase
. geometry phase where browsers calculate the position of every elementPainting phase
. The browser uses a render tree to paint or display pixels currently within your viewportRepainting phase
: if we change the DOM tree, the browser must repaint the affected regions