The timer starts every 100 ms if you add the facebook button as a button

I noticed that the Facebook XFBML button adds a timer that starts every 100 ms. Does anyone know why? Also, is it possible to delete this timer?

I think this is an error because 100 ms means that it fires very often. In addition, if you have 10 of these buttons, you will have 10 triggers that run every 100 ms, 100 triggers per second. This is a lot and can cause some performance problems.

You can check this in Chrome by opening: http://mashable.com/ (they have many similar buttons) Then just open the developer tools and the timeline tab record. You will see a lot of timer (see Snapshot http://cl.ly/272h3V1u1t3w0f1R4625 ).

+6
source share
2 answers

It seems that each similar button sets up its own poll to update it, rather than setting up a small pubsub architecture, where it has only one timer poll and alerts all subscribers.

So I would just cancel it as a bad implementation on the facebooks part and come up with them to rewrite it.

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

+3
source

Munter is right. To make matters worse, each timer also launches a fairly large number of JavaScript objects and created DOM elements. This leads to the fact that garbage collection starts wild, which has a very adverse effect on the user experience: for example, animations (both CSS and JS based) will start stuttering, and interaction depending on the real-time reaction to user input will become jerky or non-responsive. (Firefox is probably suffering here.)

First of all, each timer-executed execution also queries the DOM for the rendered sizes of the elements and calls repaints.

0
source

Source: https://habr.com/ru/post/903366/


All Articles