CSS Properties Triggering Hardware Acceleration in Safari
This article provides a comprehensive overview of the specific CSS properties that trigger hardware-accelerated compositing layers in Safari's WebKit rendering engine. By offloading specific rendering tasks from the CPU to the GPU, Safari achieves smoother animations and scrolling. Understanding which CSS declarations promote an HTML element to its own compositing layer allows developers to optimize rendering performance and prevent memory-related crashes on macOS and iOS devices.
3D Transform Properties
The most reliable way to force Safari to promote an element to a hardware-accelerated compositing layer is by applying 3D transformations. Even if the visual result remains two-dimensional, WebKit treats the element as a 3D object and hands it off to the GPU.
transform: Using any 3D function such astranslate3d(x, y, z),translateZ(z),scale3d(x, y, z),rotate3d(x, y, z, angle),rotateX(angle),rotateY(angle),rotateZ(angle), ormatrix3d(...). The declarationtransform: translateZ(0)ortransform: translate3d(0, 0, 0)is traditionally called the "null transform hack" because it triggers a layer without altering the element's appearance.perspective: Applying this property to a parent element creates a 3D rendering context, promoting the affected elements.transform-style: Setting this property topreserve-3dforces child elements to exist in a shared 3D space, triggering hardware acceleration.backface-visibility: Setting this property tohiddentriggers a compositing layer, as the GPU must calculate the 3D orientation of the element to determine if its back is facing the user.
The will-change
Property
The will-change property is the modern,
specification-compliant method to instruct Safari that an element
requires its own compositing layer ahead of an impending change.
Safari immediately promotes an element to a composited layer when
will-change is set to any of the following values:
transformopacityfilterbackdrop-filter(or-webkit-backdrop-filter)top,left,bottom, orright
Active Animations and Transitions
Safari does not always promote elements with 2D transforms or opacity
changes to the GPU while they are static. However, it will dynamically
create a compositing layer the moment a CSS @keyframes
animation or a CSS transition becomes active on specific
properties. Once the animation or transition completes, Safari typically
destroys the layer to free up memory.
The properties that trigger layer creation during active animation include:
transform: Standard 2D transforms liketranslate(),scale(), androtate().opacity: Fading elements in or out.filter: Animating effects likeblur(),brightness(), orcontrast().
Visual Effects, Filters, and Blending
Complex visual calculations are difficult for the CPU to process at 60 or 120 frames per second. Safari automatically delegates elements using the following visual properties to the GPU, even when they are not actively animating:
filter: Any value other thannone(e.g.,blur(),drop-shadow(),grayscale()).-webkit-backdrop-filter/backdrop-filter: Blurring or shifting colors of the content behind an element requires real-time GPU compositing.mix-blend-mode: Any value other thannormal(e.g.,multiply,screen,overlay) forces the browser to use the GPU to blend the element's pixels with the layers beneath it.opacity: While a simpleopacityvalue less than1does not always trigger a layer on a solitary element, it will trigger a compositing layer in Safari if the element contains child elements that already have their own compositing layers.-webkit-mask/mask: Applying image or gradient masks to an element offloads the alpha-channel calculations to the GPU.clip-path: Complex clipping paths (such aspolygon()orcircle()) often trigger hardware acceleration to handle anti-aliasing and boundary clipping efficiently.
Positioning and Scrolling
To ensure smooth scrolling—particularly on touchscreens like iPhones and iPads—Safari promotes specific layout containers to their own compositing layers:
position: fixedandposition: sticky: Elements that remain stationary while the rest of the document moves are placed on separate layers so the GPU can move the page layer underneath them without repainting the screen on every frame.overflow: scrolloroverflow: auto: Scrollable containers are given compositing layers to support momentum scrolling. In older versions of Safari, this required-webkit-overflow-scrolling: touch, though modern WebKit handles this automatically for scrollable regions.
Implicit Compositing (The Overlap Rule)
In Safari, an element can be promoted to a hardware-accelerated layer even if you do not apply any of the CSS properties listed above. This is known as implicit compositing.
If Element A is promoted to a compositing layer (for example, via
transform: translateZ(0)), and Element B sits visually on
top of Element A due to a higher z-index or later DOM
order, Safari must also promote Element B to its own compositing layer.
Otherwise, the GPU-rendered Element A would incorrectly render on top of
the CPU-rendered Element B. Developers must manage z-index
carefully to prevent one intentional GPU layer from inadvertently
creating dozens of implicit layers, which can exhaust device memory and
crash the Safari tab.