开发者

Something bugging me about Facebook Timer

开发者 https://www.devze.com 2023-01-27 01:57 出处:网络
If you have used Facebook, you might have the noticed there is a timer in everything that appear开发者_运维百科s on the page, which are constantly updating in minutes. Which, I am wondering is not aff

If you have used Facebook, you might have the noticed there is a timer in everything that appear开发者_运维百科s on the page, which are constantly updating in minutes. Which, I am wondering is not affecting the performance of the website.

Whether It is a Ajax Request triggered by a timer or Just plain client side Timer, the point is a lot of timers are used. Wont using a lot timers like this affect the site's performance? or There is something I am missing.


It only takes one timer to do what Facebook is doing. Each time it fires, it iterates over all abbr elements with class="timestamp and calculates an update based on the custom data-date attribute they've defined.


Sure, anything you add that runs a setInterval() will change the performance of a website.

However, unless Facebook shows time down to the second, it probably runs once a minute.

I've also noticed Facebook uses lot of fuzzy times, like just then, etc. This may mean the setInterval() runs on an even longer interval.

0

精彩评论

暂无评论...
验证码 换一张
取 消