FastDOM - Read / write every 17 ms?

FastDOM is a small library that sells the DOM, reads and writes to raf (requestAnimationFrames).

https://github.com/wilsonpage/fastdom

I read the code, however, I'm struggling to figure out how this works. Here are a few presumptions that we have: - Browsers are usually set at 60 frames per second - Thus, in general, there can be a maximum of 60 graphs per second

That is, each FastDOM read / write batch will work after 17 ms (1000 ms / 60 frames per second). Wouldn't it be too slow, since a function can have read / write calls one by one?

Obviously this is not the case, but Im confused and would be grateful for the clarification.

Thank,

+4
source share
1 answer

Both types of DOM operations (read / write) have their own job queues. Each queue is reset (for example, all tasks are started / executed) eachrequestAnimationFrame

If you add 100 read operations in just 5 ms, for example (during a cycle, for example), all these read operations will (most likely) happen the next time the queue readis reset (this may be 1 ms after adding the last job or 16.66667 ms after adding the last job).

Read the source, it is well written and well commented.

+6
source

All Articles