What forces layout/reflow. The comprehensive list.
All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.
elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParentelem.clientLeft, elem.clientTop, elem.clientWidth, elem.clientHeightelem.getClientRects(), elem.getBoundingClientRect()elem.scrollBy(), elem.scrollTo()elem.scrollIntoView(), elem.scrollIntoViewIfNeeded()elem.scrollWidth, elem.scrollHeightelem.scrollLeft, elem.scrollTop also, setting themelem.focus() can trigger a double forced layout (source)elem.computedRole, elem.computedNameelem.innerText (source)window.getComputedStyle() will typically force style recalc (source)
window.getComputedStyle() will force layout, as well, if any of the following is true:
min-width, min-height, max-width, max-height, width, heightaspect-ratio, min-aspect-ratio, max-aspect-ratiodevice-pixel-ratio, resolution, orientationheight, widthtop, right, bottom, leftmargin [-top, -right, -bottom, -left, or shorthand] only if the margin is fixed.padding [-top, -right, -bottom, -left, or shorthand] only if the padding is fixed.transform, transform-origin, perspective-origintranslate, rotate, scalewebkit-filter, backdrop-filtermotion-path, motion-offset, motion-rotationx, y, rx, rywindow.scrollX, window.scrollYwindow.innerHeight, window.innerWidthwindow.getMatchedCSSRules() only forces styleinputElem.focus()inputElem.select(), textareaElem.select() (source)mouseEvt.layerX, mouseEvt.layerY, mouseEvt.offsetX, mouseEvt.offsetY (source)doc.scrollingElement only forces stylerange.getClientRects(), range.getBoundingClientRect()More on forced layout section below covers everything in more detail, but the short version is:
for loops that force layout & change the DOM are the worst, avoid them.rAF, scroll handler, etc), when the numbers are still identical to the last time layout was done.
Timeline trace of The Guardian. Outbrain is forcing layout repeatedly, probably in a loop.
updateLayoutIgnorePendingStylesheets - GitHub search - WebKit/WebKit FrameNeedsReflow - mozilla-central searchupdateLayoutIgnorePendingStylesheets - Chromium Code SearchupdateLayoutTree - Chromium Code SearchCSS Triggers is a related resource and all about what operations are required to happen in the browser lifecycle as a result of setting/changing a given CSS value. It's a great resource. The above list, however, are all about what forces the purple/green/darkgreen circles synchronously from JavaScript.