-
Notifications
You must be signed in to change notification settings - Fork 949
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
Remove POS selectors #293
Comments
You mean in 3.0? |
Yea, thanks |
Actually, may not be 3.0 either. |
This is a HUGE change, but I'd be much happier with a POS-free Sizzle. How can properly we evaluate the palatability of dropping those selectors, though? |
@gibson042 I figure we can start by keeping it separate from Sizzle master and see how much traction we can get. |
I can't really see any third-party-developers benefit from this. The entire idea behind jQuery is "let me do things easily, whitouht having to implement them myself". If you start stripping features just because jQuery is getting fat, you're basically giving up the idea behind jQuery. |
The benefit is not just size/simplicity. These selectors were created before qSA existed and we've discouraged their use since then. Even if they don't get removed, don't use them. The better alternative is to use POS methods like |
Just to be sure I'm not missing anything here. Can't I can't see any pros, while I can see huge cons, like breaking pretty much every single jquery-based code. |
The selector syntax is its own language that must be parsed and executed. That's Sizzle's job. The
Right, but we would prefer to let people do things that represent good performance and best web practices. A gun can shoot your foot easily, but that is generally not considered best practice. Over time we've removed things like |
You're mixing good-practices with easy-to-use tools. A selector (instead of a call to a method inside jQuery) that would add a few ms to the total amount of time required to do the thing is hitting the 99.99% of the "yeah, I can live with an extra 15ms in my code" cases. Now, for the other 0.01% of the cases that actually use Long story short: don't try to over-optimize jQuery by stripping useful (and used!) functions just to make it faster and lighter, because in the end of the day you're trading speed for developer's time (which is why jQuery exists in the first place). |
The problem with positional pseudos is that they can appear anywhere in a selector— For cases using only a single positional at the end of a single selector (e.g., |
Yes there is a big perf penalization. I'm typically not one for JS perf results but: http://jsperf.com/jquery-first-vs-first-vs-eq-0-vs-0/18#bs-chart I understand this does regress the developer ergonomics somewhat, but your users will appreciate it. |
Although, with the new "check the cache first" change that is in 3.0 the penalty goes from about 8x to only 2x: http://jsperf.com/jquery-first-vs-first-vs-eq-0-vs-0/19 |
So it seems like we probably won't be able to remove positional selectors in 3.0 since we haven't come to a decision and haven't communicated it yet. Could we agree to deprecate them for 3.0 so jQuery Migrate could give console warnings? That would be a good start. |
@dmethvin We had a long talk about it with @gibson042 at the summit and @gibson042's plan was to first prototype something outside of Sizzle, directly inside jQuery - basically to have the In light of that, deprecating those selectors in Sizzle might not make sense but we could deprecate them in jQuery. This is definitely not making it into 3.0.0, it's too late for such experiments. @gibson042 Please correct me if I messed your intentions. |
Not at all @mzgol; that's a good summary. I think Sizzle and especially jQuery should deprecate positional selectors. It doesn't mean they'll come out anytime soon, but it does mean that they're on notice and officially discouraged, and subject to removal in any future major release. |
This will not happen in Sizzle but it will in jQuery. I migrated the issue to jquery/jquery#4396. |
Of all of the features in Sizzle, positional selectors (
:first
,:last
,:eq
, etc.) are the most cumbersome and problematic. If these were removed from Sizzle, it would greatly simplify the codebase, reduce code size drastically, and set Sizzle on the same track as the Selectors spec. Obviously, this would have a major impact on user code, but we could start with a branch and make it an optional replacement in jQuery. Hopefully, we could see positional selectors phase out of Sizzle completely some time in the distant future.Note: this is a much more significant size decrease than dropping old IE.
The text was updated successfully, but these errors were encountered: