I'm creating a website that has an ::after element with a backgound and a CSS3 blur applied. I've noticed that applying the CSS3 blur has a huge detrimental effect on performance.
With CSS3 blur applied, there is about a 10 - 20 frames/second drop (from 60fps).
The reason I used CSS3 filters to apply a blur was because this is generic code applied to images that I want blurred, ie, I don't want to use an image editor to blur the images manually.
.blur::after { background-image:url(dog.png); filter:blur(3px); }
So, my question is, are there alternatives to using filter: to blur an element and its background that have better performance without using an image editor?
ps, I don't mind using javascript, jquery, css, or html elements.
The filter CSS property applies graphical effects like blur or color shift to an element. Filters are commonly used to adjust the rendering of images, backgrounds, and borders. Included in the CSS standard are several functions that achieve predefined effects.
The blur() function is an inbuilt function which is used to apply a blurred effect filter on the image. Parameters: This function accepts single parameter radius which holds the blur radius in form of length. This parameter defines the value of the standard deviation to the Gaussian function.
The backdrop-filter CSS property lets you apply graphical effects such as blurring or color shifting to the area behind an element. Because it applies to everything behind the element, to see the effect you must make the element or its background at least partially transparent.
Syntax. filter: blur(px); To apply a blur effect to the background image, with the blur function use the z-index property to set the stack order of the element, set the width and height 100% to have a full background image.
I was having the same problem. I decided to try adding a CSS snippet used for improving performance of 3d CSS translation. It worked! Not sure why - I'd love if someone could enlighten me. (It might just be that the snippet induces GPU rasterization?)
-webkit-backface-visibility: hidden; -webkit-perspective: 1000; -webkit-transform: translate3d(0,0,0); -webkit-transform: translateZ(0); backface-visibility: hidden; perspective: 1000; transform: translate3d(0,0,0); transform: translateZ(0);
Note that I applied these styles to the element overlaying the blurred element.
I only did a very limited amount of testing; if anyone wants to do some rigorous benchmarking or provide some insight into this issue, it would be greatly appreciated.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With