Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Timer fired every 100ms if you add a facebook like button

I have noticed that Facebook's XFBML like button adds a timer that triggers every 100ms. Does anyone knows why? Also, is it possible to remove this timer?

I think this is a bug because 100ms means it fired very often. Also, if you have 10 like buttons you will have 10 triggers fired every 100ms, 100 triggers per second. That's a lot and can causes some performance problems.

You can check this in Chrome by opening: http://mashable.com/ (they have a lot of like buttons) Then just open developers tools and from timeline tab do a record. You will see a lot of Timer fired (see snapshot http://cl.ly/272h3V1u1t3w0f1R4625).

like image 963
julbmann Avatar asked Dec 08 '11 11:12

julbmann


1 Answers

Looks to me as if each like button sets up it's own polling to keep updated instead of setting up a small pubsub architecture where it only has one timer polling and alerting any subscribers.

So I'd simply discard this as a bad implementation on facebooks part and take it up with them to rewrite it.

Pubsub is really not that difficult to implement. Just take a look at this implementation: https://github.com/daniellmb/MinPubSub

like image 113
Munter Avatar answered Oct 11 '22 13:10

Munter