Lighthouse: Avoid non-composited animations
Avoiding non-composited animations can speed up your page load and prevent page jank i.e., your page stuttering or appearing visually unstable when it loads.
How does your site score on this audit?
How do non-composited animations affect browser rendering?
To understand how non-composited animations affect your page performance, you must first understand how the browser renders your page.
There are 6 steps that the browser needs to follow in order to render your page, collectively referred to as the rendering pipeline.
With the exception of the last step (i.e., compositing), every other step in the rendering pipeline is directly affected by the steps that precede it.
Note that the first five steps (also known as non-composited steps) are executed on the main-thread, by default, and the compositing step is executed on a separate compositor-thread.
How do non-composited animations affect page performance?
As mentioned earlier, each step in the browser's rendering pipeline directly affects the subsequent steps in the pipeline.
The effect on your page performance is primarily two-fold:
- Firstly, your browser has to do more main-thread work to render the page, increasing the execution time.
- Moreover, it introduces more layout shifts on your page due to the changing elements, which can be triggered by additional steps in the rendering pipeline.
Avoiding non-composited animations can reduce main-thread work, delivering a better user experience.
Composited animations (i.e., opacity, transform) are executed on a separate compositor-thread and will not trigger re-painting of pixels. This ensures that your page loads smoothly, avoiding unexpected layout shifts and/or page jank.
How does GTmetrix trigger this audit?
GTmetrix checks if any of the animated elements on your page are non-composited.
If there is at least one such element, this audit triggers.
Clicking the audit reveals the non-composited animation elements.
How to avoid non-composited animations?
In general, try to only perform composited animations, especially, for the animated elements identified by GTmetrix.
Start by evaluating the CSS elements used for your animations. Click here for a complete list of CSS elements that may or may not trigger repainting of pixels on your page.
Note: This is an expert-level optimization
Only experienced developers are advised to improve this audit.