估计JS浏览器的发动机转速有条件地禁止动画 [英] Estimate browser JS engine speed to conditionally disable animations

查看:141
本文介绍了估计JS浏览器的发动机转速有条件地禁止动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一个标准(接受/易/高性能)的方式来确定客户机如何快速地渲染JavaScript的?

Is there a standard (accepted/easy/performant) way to determine how fast a client machine renders javascript?

当我在我的其他选项卡我的JS动画慢如蜗牛运行Web应用程序(视频等)。

When I'm running web apps (videos, etc) on my other tabs my JS animations slow to a crawl.

如果我可以从我的JS检测缓慢,我会用更简单的动画,以提供更好的用户体验。

If I could detect slowness from my JS, I would use simpler animations to provide a better user experience.

更新:

删除动画为大家也不是办法。我说的是,这将取决于口吃浏览器/电脑动画的简单。如果我能检测出缓慢的水平,我想简单地禁用它们。

Removing animations for everyone is not the answer. I am talking about the simplest of animations which will stutter depending on browser / computer. If I could detect the level of slowness, I would simply disable them.

这是一样的动态图形质量的视频游戏:你想取悦与旧电脑的人没有惩罚那些谁拥有额外的处理能力。

This is the same as video games with dynamic graphics quality: you want to please people with old computers without penalizing those who have the extra processing power.

推荐答案

我知道这个问题是旧的,但我只是通过它绊倒了。最简单的方法是执行一个长循环和测量的开始和结束的时间。这应该给你机器的JavaScript性能有所了解。

I know this question is old, but I've just stumbled across it. The simplest way is to execute a long loop and measure the start and end time. This should give you some idea of the machine's Javascript performance.

请记住,这可能会延迟页面加载,所以你可能需要将结果存储在cookie,所以它不是到每次访问页面时测得的。

Please bear in mind, this may delay page loading, so you may want to store the result in a cookie, so it's not measured on every visit to the page.

是这样的:

var starttime = new Date();
for( var i=0; i<1000000; i++ ) ;
var dt = new Date() - starttime;

希望这有助于。

这篇关于估计JS浏览器的发动机转速有条件地禁止动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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