

Resize Text 200: The page SHOULD be functional when only the text is magnified to 200 of its initial size.

We can reduce this to a single reflow which is also easier to maintain, e.g. Accessibility Techniques for Text Styles, Resize, Reflow, and Zoom. This simple example causes three reflows: var myelement = document. Performance can be improved by updating all DOM elements in a single operation. Fortunately, there are several general tips you can use to enhance performance. Some elements are more expensive to render than others. Some browsers are better than others at certain operations. The reflow processing flow hit will vary. Changing the width of an element can affect all elements on the same DOM branch and those surrounding it.Įvery frame of the animation will cause a reflow.īizarrely, reading an element’s offsetWidth and offsetHeight property can trigger an initial reflow so the figures can be calculated.įinally, the user can trigger reflows by activating a :hover effect, entering text in a field, resizing the window, changing the font dimensions, switching stylesheets or fonts. Similarly, directly applying CSS styles or changing the class may alter the layout. The first is obvious using JavaScript to change the DOM will cause a reflow. It’s useful to understand when reflows are triggered:Īdding, removing or changing visible DOM elements This is one of the reasons you encounter issues such as jerky scrolling and unresponsive interfaces. In extreme cases, a CSS effect could lead to slower JavaScript execution. Changing a single element can affect all children, ancestors, and siblings.īoth are browser-blocking neither the user or your application can perform other tasks during the time that a repaint or reflow occurring. This refers to the re-calculation of positions and dimensions of all elements, which leads to re-rendering part or all of the document. Repaints are expensive because the browser must check the visibility of all other nodes in the DOM - one or more may have become visible beneath the changed element. For example, opacity, background-color, visibility, and outline. Two terms are used in the browser world when visual affects are applied:Ī repaint occurs when changes are made to elements that affect visibility but not the layout. That said, I’m guilty of adding superficial CSS3 animations or manipulating multiple DOM elements without considering the consequences. The slicker your application, the better the user experience and the higher the conversion rate! Despite web pages reaching 2MB performance remains a hot topic.
