CSS动画比JS动画快吗? [英] Are CSS animations faster than JS animations?

查看:84
本文介绍了CSS动画比JS动画快吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我前一段时间读到一些东西,说CSS动画比JS动画快.使用jQuery制作某些动画后,我可以理解为什么有人会这样说,因为jQuery动画有时会出现故障且运行缓慢.但是我想知道的是,论点中是否有任何铁腕真理?

I read something a while ago that said that CSS animations are faster than JS animations. Having used jQuery to do some animations I can see why some would say this, as jQuery animations are sometimes buggy and slow. What I would like to know however, is whether there is any hardcore truth in the argument?

推荐答案

有一个普遍的误解,认为CSS动画比JS动画要快,因为每当提到该主题时,都会使用所有的高脂蛋白流行语.但是,CSS动画比jQuery动画快得多且更稳定,这是很多人从中获得灵感的地方.如果您查看用于JS的GreenSock库(名称应与旧版Flash WebDevs:v响起钟声),它比jQuery快得多,并且比CSS动画更胜一筹.

There is a common misconception that CSS animations are faster than JS animations because of all the highfalutin buzz-words used whenever the topic is brought up. CSS animations are however much faster and more stable than jQuery animations, which is where a lot of people get this idea from. If you take a look at the GreenSock library for JS (the name should ring bells to old Flash WebDevs :v), it is considerably faster than jQuery, and more than a match for CSS animations.

如果您在此网站上查看 ,然后向下滚动到性能比较"部分,您进行了压力测试,这实际上是我刚才所说的一切的基础.我在装有Intel Core i7 3930K 3.2GHz处理器和8GB RAM(无法分辨是什么GPU)的机器上进行了测试.

If you take a look at this website and scroll down to the 'Performance comparison' section, you have a stress test that is indeed the basis of all of what I just said. I ran the test on a machine that has an Intel Core i7 3930K 3.2GHz processor and 8GB of RAM (Cannot tell what GPU).

运行测试时,请确保将点设置为3000并在所有三个引擎上运行测试.

When running the test, make sure to set the dots to 3000 and run tests on all three engines.

  • jQuery引擎只能呈现单个点
  • GreenSock引擎是迄今为止最流畅的
  • CSS引擎不错,但看起来不像GSAP引擎那么流畅

很明显,如果有人不同意所提供的测试和信息,请提供有关您为何不同意的参考和数据

这篇关于CSS动画比JS动画快吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆