Is there any advantage to using CSS animations over jQuery animations? (performance, or otherwise)

前端 未结 6 1053
执念已碎
执念已碎 2021-01-12 11:59

I mean, CSS animations are cool, but CSS3 compliance is annoyingly un-standard. but, ignoring all the issues with browsers and their inability to be up-to-date with the late

6条回答
  •  悲&欢浪女
    2021-01-12 12:49

    As a general rule of thumb, whenever JavaScript can be avoided and the same result achieved, it should be avoided.

    It's always preferred to use the native browser abilities as it will usually be better performance-wise, plus it will generally look better.

    Additional points:

    • jQuery animations are not real animations, they are faked, while the native CSS3 browser animations are in fact, animations. As a result native CSS3 animations can be accelerated by the GPU, whereas jQuery animations cannot.
    • Do note that not all browsers support CSS3 animations/transitions. You would probably want to test if the browser supports it, and act accordingly.

提交回复
热议问题