-
-
Notifications
You must be signed in to change notification settings - Fork 68
DOM Optimizer
Recently, we began releasing a prototype "DOM Optimizer". The code likely seems very confusing (in what it does), so here I'll summarise for technical and hopefully less technical people.
The DOM (document object model) is the layout of the page as defined by elements, which can be the entire chat panel, or individual messages or pieces of text. When the DOM changes, the browser has to paint - compute layout and what it should look like, then draw it to the screen. When this happens, especially in large chunks, it causes a noticeable lag to the user.
When switching channels (or servers), there are many DOM changes which take place, big and small. The entire main chat panel is removed and readded, but also every member's activity text is changed. All of these are done in one large bulk chunk with React.
OpenAsar's DOM Optimizer delays some unimportant DOM changes for later (100ms), currently mostly member activity (RPC) status text.
Why? Instead of currently doing this:
- Switch channel
- All DOM changes
- Large lag and wait...
- Paint, usable again
With the DOM Optimizer, it now does:
- Switch channel
- Important DOM changes
- Less major lag and wait
- Paint, usable again earlier/faster
- Less important DOM changes
- Second paint, now identical to normal
On my setup, this made switching channels noticeably quicker. Hope it does for you too :)