In this article, the author states do not need permanently store style will-change css style file will-change: transform;
, and should be added dynamically using javascript
Аlso the author the example script:
var el = document.getElementById('element');
// Set will-change when the element is hovered
el.addEventListener('mouseenter', hintBrowser);
el.addEventListener('animationEnd', removeHint);
function hintBrowser() {
// The optimizable properties that are going to change
// in the animation's keyframes block
this.style.willChange = 'transform, opacity';
}
function removeHint() {
this.style.willChange = 'auto';
}
Can I use this script, and whether he to be useful to me?
$('.my_class')
.mouseenter(function() {
$(this).css("will-change", "transform");
})
.mouseleave(function() {
$(this).removeAttr("style");
});
I will be glad to hear suggestions on how to make effective use of style will-change