Sizzle revamp
This ticket is for tracking enhancements and reductions for Sizzle. Some of these may belong in separate tickets, but I need to compile the list somewhere. I plan on doing/researching all of this in 1.8.
These are my ideas so far:
- Reorganize the main Sizzle function to be one function that contains shortcuts for id, tag, class, and document.body and an internal select function that uses qsa if available. Sizzle somewhat does this already, but not completely. I think it would reduce the size of Sizzle itself. We also do some of this in jQuery.fn.init and duplicate some of what is already in a qsa Sizzle. This could remove the need for that duplication and shave even more bytes.
- This may not be feasible, but I want to look into adding local vars for the most common things referenced from within Sizzle instead of using.long.property.accesses internally.
- The implementation of prefilters seems a bit wet. I'd like to dry up some of that code and look into reducing the call stack on that codepath.
- Add a support-test regex builder for places in which we know QSA will fail, such as with :checked on select elements in webkit (there are about 6 others). This should not hurt performance at all if done correctly.
- Remove matchesSelector support completely. I know this sounds scary, but as Dave noticed in his event testing, even the native matchesSelector is really slow. It may actually be faster, especially in the most common use cases, to do our own filtering all the time. This could also remove the need for quickIs in event.js.
- Combine dirNodeCheck and dirCheck into a single function.
- Add a better fallback for Sizzle.contains.
- There are a couple tests for Opera 9.6 and Safari 3.2, which we don't support anymore, for getElementsByClassName. We could remove that cruft.
- Look into simplifying Sizzle's makeArray to not use Array slice at all. When building minimaljs, I noticed that a simple array builder is actually faster than using slice, so it does not seem worth it.
- Check how many bytes it would save to build the chunker and all other regexes using strings to reduce duplication.
- Follow spec for acceptable character ranges. Currently, we use "\u00c0-\uFFFF\", which may not be correct. third party pull https://github.com/jquery/sizzle/pull/61
Change History (15)
Component: |
unfiled →
selector
|
Milestone: |
None →
1.8
|
Owner: |
set to Timmy Willison
|
Priority: |
undecided →
blocker
|
Status: |
new →
assigned
|
Keywords: |
1.8-discuss added
|
Description: |
modified (diff)
|
Description: |
modified (diff)
|
Description: |
modified (diff)
|
Description: |
modified (diff)
|
Description: |
modified (diff)
|
Blocking: |
7010 removed
|
Keywords: |
1.8-discuss removed
|
Resolution: |
→ fixed
|
Status: |
assigned →
closed
|
+1 !!!!!!