Skip to content

Performance impact: sizzle don't use querySelectorAll for specific selector after using $('...').filter('selector') #393

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
miflinak opened this issue Nov 6, 2016 · 0 comments · Fixed by #418
Milestone

Comments

@miflinak
Copy link

miflinak commented Nov 6, 2016

Steps to reproduce

  1. Use filter, for example $('any selector').filter('a, div') (useless but it's just an example).
  2. Call $('a, div') and sizzle wouldn't use querySelectorAll!

That happends because there compilerCache exists for that selector (it was cached when we called filter).

Example: http://jsbin.com/qidopuhiro/1/edit?js,console,output
1 ms vs 15 ms in my case (desktop).

Why that happends?

See

!compilerCache[ selector + " " ] &&

We can just remove this line. Or do something more complex (like marking cache as filter-only).

You can say "hey, that's just a 15 ms!". But that's much slower on mobile (for example 10 ms vs 150 ms) or when there's many selectors or selectors are complex.
Anyway, why not to use querySelectorAll in cases when we can use it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

2 participants