Search code examples
cssgoogle-chromecss-selectorspseudo-class

Chrome - nth-child rule is too slow


I've been testing DOM selecting performance using jQuery. I get some questions after comparing $("ul li:nth-child(999)") to $("ul li").eq(999)

$("ul li:nth-child(999)");
$("ul li").eq(999);


Please click on the following link to see my detailed test results :

JSPerf Test Result

Especially Chrome shows poor performance for operating nth-child pseudo classes.
I want to know why such a result is caused.
Can I get any algorithm, mechanism or references about that?

I would be very grateful if someone helps me.
Thanks.


Solution

  • I couldn't find any answer about this question anywhere, think that it can be an unknown bug. So I sent an email to Chromium Team, this issue has been ticketed on Chromium forum officially.

    You can see the ticket for nth-child issue on the following link :

    https://code.google.com/p/chromium/issues/detail?id=364081&q=nth&colspec=ID%20Pri%20M%20Iteration%20ReleaseBlock%20Cr%20Status%20Owner%20Summary%20OS%20Modified

    Thanks.