jquery / sizzle

A sizzlin' hot selector engine.
https://sizzlejs.com
Other
6.29k stars 951 forks source link

Randomly generated id attribute #405

Closed asdfgh11111 closed 7 years ago

asdfgh11111 commented 7 years ago

Hi, I'm trying to figure out why our app has big delay in Edge. The case quite trivial. I have wizard with couple forms. Delay appears on switching from one form to another.

Here is what I found in dev tools: image

Seems our app performance quite suffer from internally generated id attribute which triggers style recalculation. It's just one expanded on the screen but there are dozen "offsetWidth"s below.

Any ideas how to except it?

PS win64, Microsoft Edge 40.15063.0.0, Microsoft EdgeHTML 15.15063

gibson042 commented 7 years ago

We generate that id to ensure that all components of compound selectors match children of the context element (e.g., so $ul.find("ul li") runs code like ul.querySelectorAll("#id-of-ul ul li") instead of the naïve ul.querySelectorAll("ul li"), which would match all the descendant <li> elements). But we skip generation/assignment if the context element already has an id, so the best thing you can do is ensure that it does before invoking a selection.

asdfgh11111 commented 7 years ago

Set id to form and got 1s instead of 4s. Other recalculations seems not related to selectors. Though, hope u sure querySelector worth it :)