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
You should pay special atention to this paragraph in the article that you link (the emphasis is mine)
So, if you are planning to make some kind of effect on hover, setting the will-change property on hover isn't going to make any visible difference