Improved tooltip setup performance
authorAlexander Ebert <ebert@woltlab.com>
Fri, 1 Sep 2017 10:18:16 +0000 (12:18 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Fri, 1 Sep 2017 10:18:16 +0000 (12:18 +0200)
commit9bac3eb6c28abed120852f5e61c4af1ec81e57d8
treed63ca9ae87cbd2f522fc323cc02e7b26632d148a
parent4831444fe0d19e90a18b85502fcb47efa1faddb3
Improved tooltip setup performance

The live collection of `getElementsByClass()` shows a bad performance
when a large list of elements gets remove one-by-one.

It took around 1 second to process 4k elements and stripping the class
from each one. Using `querySelectorAll` instead does the same job in
less than 40ms.

The check against `_elements` is still in place, because it performs
pretty well with large sets of DOM elements (tested with ~16k elements)
and allows us to return early without invoking the costly
`querySelectorAll`, which even without results hit with 0,2 seconds
during tests.
wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Tooltip.js