Profiling a page with the built-in timeline recorder in Chrome, I see repeated "Recalculate Style" entries. They have no obvious information to link them to DOM element or event.
How can I best determine the cause of these entries?
Profiling a page with the built-in timeline recorder in Chrome, I see repeated "Recalculate Style" entries. They have no obvious information to link them to DOM element or event.
How can I best determine the cause of these entries?
I was able to test if CSS transitions or animations were triggering recalculations on my page. I used jQuery to do this, but you can use whatever you want:
This effectively disables transitions and animations on every element of your page. I ran them one at a time, and then reran my profiling. In my case, animations were the culprit.
.css('animation')
will return something likeor if there is no animation,
So after refreshing (to reenable the animations), the following snippet logs every element that has an animation defined:
By disabling animations on each of those individually, I was able to determine which one was causing my issues.
I'm almost sure you have some infinite repeating animation on your page. That's what caused Recalculate Style without saying what caused it.
An alternative to the posted jQuery version for investigation is a simple one-liner in the console:
This will print a line every time some animation runs, including the name of the animation and the element where the animation is applied to.
My advice to you would be to use the Chrome Canary build of Chrome. Paul Irish has a good demo of using the Timeline in Chrome Dev Tools here
You can simply click on the event, for instance 'Recalculate Style', and you should get a miniature stack trace pointing to where the event occurred in your code.
I just had the same problem (that's why I found your question).
My problem was cause by a CSS3 transition all property. I had been lazy, when all I needed was transition padding.
Implementing that single change made the loop