are these `li` elements direct children of the container ?

If yes, then you should iterate using firstElementChild etc, which is really faster than the current loop. And we know how this can be a problem when we have lots of threads...