The placement of the rAF call becomes clearer if you remember that requestAnimationFrame just asks for a ride in the next animation processing loop - this does not actually cause the animation processing loop.
Calling the next rAF frame immediately gives you the best chance of catching the next cycle of the rAF cycle.
For example, if your βmaterialβ takes about 3 ms, and the next rAF cycle starts after 4 ms, you can catch the next cycle in 4 ms, and not the next cycle in 4 + 16 ms. It may not seem possible that you will skip the next rAF cycle, since you have 4-3 == 1 ms (almost an eternity for the processor), but the system can plan other things that eat up your 1 ms supply (for example, garbage collection) .
On the other hand, if your βstuffβ averages 15 ms to complete, enter your rAF call at the end. Transferring the latter may skip execution once and for a while, but this is probably better than risking the accumulation of a few "things."
Given this, in general, enabling the rAF call at the end is safer for the random cost of the skipped rAF cycle.
source share