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
Deprecate event shorthand methods #3214
Comments
Please DO NOT do this. A huge amount of code, especially in top 1 million websites, relies on a LOT of these event shorthands. The reason A good example: We would have to change Please do not break such important shorthands just because one person complained about it. The biggest reason to continue to use any library is its backward compatibility. If it keeps breaking stuff for ZERO apparent gain, then many users will either seriously consider moving to different library or stay with older version. I am guessing jquery does not want that. In addition, there are millions of jquery plugins which uses these shorthand and there is no way every single one of them would be updated. This would break the entire jquery ecosystem. I hope you guys see the magnitude of this change. Not only do users not gain from this; but it will break lots of stuff for no reason. EDIT by @mgol: put code in code snippets to avoid errors coming from GitHub math mode |
I'm +1 on deprecating, -1 on ever removing from the default build. It's already easy to exclude in a custom build, but the deprecation is a good signal to developers that they should aim to not use them. |
I'm not a fan of deprecating something we don't plan on removing. Considering that, I might be a -1 on deprecating these. They're just too prevalent to remove, and I don't see the downside of using them if you like them. I prefer |
The reason I'm in favor of deprecating, but not removing is that it will encourage plugin developers to support users who want to exclude the event alias module. This is the only module, besides the deprecated module, that we support excluding with jQuery UI. I've also personally disliked these methods for many years because they operate in the reverse order of what's expected for the trigger scenario (the primary action is firing an event, not taking an action like the native equivalents). The result is close enough to the expected, native behavior that most developers don't notice, but it's definitely been a source of pain for a long time. |
The Bootstrap team has a similar thought to @scottgonzalez in twbs/bootstrap#20203 and are planning to use the slim build. Obviously most consumers of Bootstrap will be using the full build but it's nice for end-developers that a plugin doesn't unnecessarily force them to use a full build. I'm fine with deprecating but not ever removing. Slightly more complicated, we can not deprecate it and come up with another term and use that in the API docs to define APIs that plugins should avoid. It's already possible to exclude event-alias in a custom build, but without some signal to plugin writers about what to avoid that isn't going to help much. To @john2014's concern, even if we removed event aliases in the core library we have always provided plenty of compatibility helpers to make the transition easier. If someone is moving from jQuery 3 to a hypothetical jQuery 4 without event aliases, they would just add jQuery Migrate 4 at the time they changed to jQuery 4 and it would report the things to fix. |
To add to the above points, deprecating these shorthands will mean the slim Michał Gołębiowski |
It's also interesting that Bootstrap actively disables aliases in their unit tests so they won't accidentally be used. They could have used a custom build of course but this way their tests generate a clear error message if one is used accidentally. |
I agree with @john2014 that the tradefoff is not worth it (saving few lines of code vs breaking a lot of user code + lots of jquery plugins - maintained or unmaintained; but actively used).
The most important point is backward compatibility. Users should not have to keep modifying their code (and every jquery plugins they used), everytime a new jquery major version is released. Note: Jquery migrate will certainly solve that "newly created" problem. But that will involve users having to add two javascript sources instead of one. Many users may not even be aware that Jquery migrate exists. I dont think saving few lines of code is worth breaking lots of code. As you may know, Jquery is already less than 34 KB when you load it from Google CDN and its permanently cached. Reducing files size to 33 KB (or even 29 KB) isnt going to make much difference. A single image on Facebook is more than 60 KB. So filesize should not be an important criteria. IMHO, the most important criteria should be backwards compatibility and adding new features to continue to make Jquery a great library. |
@BillJones50 @john2014 I think the whole core team agrees that these should not be removed. Some would like to warn against their use, though, and deprecation might be the best way to do that. However, I still think the word "deprecation" will give the wrong signal. That is, some people will believe jQuery intends to remove them down the line (as is evidenced by @BillJones50's comment), and we don't. |
Thank you @timmywil I forgot to add that using shorthand not only saves significant coding time, but also reduces end user filesize (since there is less code). Using shorthand is a win-win for developers. |
Both are a lie. You don't save significant coding time with any shorthands like this. The time it takes to type a few characters is negligible, even over an entire year's worth of coding. Even the time you spend typing in general while coding is fairly small. Keystrokes are not where you get significant gains in development time. As for end user file size, I assume you're referring to the number of bytes transferred, not the number of bytes in the cached file on the user's drive. The number of bytes you think you're saving during transfer (bandwidth) disappears when the code runs through gzip prior to the transfer. |
You do realize that not everyone uses Gzip on their server. In addition gzipping (compression) increases server loads (it has to compress every single time unique visitor requests javascript files) and is not suitable for all situations. If we can compress codes (using shorthands) before the gzip process, its lot more useful. I am not sure why you think providing quick shorthand is a problem. Shorthands (called symbolic links) in Linux OS is very widely used and is a feature that should be advertised for saving time/money and not something to be hidden from users. |
Breaking backwards compatibility is precisely the reason for releasing a new major version. Not every user will have to modify code, but it is a guarantee that at least some will. So please consider this a strong suggestion to avoid event shorthand methods in all new code. |
I think there is confusion about term "deprecating". Let's go to the wikipedia page for the definition -
without removing - purpose of tickets like that is only to discourage use of it. Nothing more. For example, DOM method We could use same rule - not remove those widely used methods until no one uses them with newer version of jQuery, meanwhile, if we unfavor this practise we should show it. That's all it is. Not the first time i see this misconception which really sadness me, i urge everyone to see formal limitations of this term. |
Can we move it to 3.2.0? 3.1.0 is almost ready (in fact, I moved all issues previously assigned to 3.1.0 to 3.2.0). |
@markelog A formal definition has little bearing on the popular connotations associated with a term, which is why dictionaries change with time. Your point does not change my belief that "deprecation" implies eventual removal, at least to some. I wish there was a way we could say that we recommend avoiding a particular API, which is different than saying we recommend avoiding it and it may be removed in a future version. |
@timmywil How about if we changed the name of the |
Yeah if we're not going to use Deprecated for these then we should come up with another term. We've got quite a few of these "Deprecate X" issues open and they seem to be blocked on coming to an agreement about this. |
It does imply that to some because it is a first step in removal process, there isn't any other way really, we can call any way we prefer - It wouldn't change the meaning of what we are doing which is discouraging people from using it, so it still would be the first step in removal process |
I actually don't think deprecation must mean plans to remove in the nearby future. I would say, though, that deprecating sth means we discourage using it and we'd love to remove it but who knows if and when the removal will be possible. If we don't want to remove it not due to widespread usage but just because we think this API should continue to exist then why would we discourage using it? Those two things don't really go hand in hand with each other. Applying that to this ticket, I'd say that since we want to discourage it, we should deprecate it even if we can only remove it in 5 or 10 years. |
That's exactly what i'm trying to say, thank you |
There is some precedent for long deprecation. We deprecated The main issue here is that the longer we wait to send the signal "this isn't best practice anymore" using whatever word, the longer it will take for people to change their code because they're not aware of it. Just like |
Is there a particular reason some Jquery members want to actively discourage using shorthands? The only reason I can think of is reducing file size (by eventually removing it - whenever that would be). So I did actual calculations and after minify+Gzip, it only saves around 400 bytes. Is there any other reason? |
|
If these shorthands aren't likely to ever be removed, why not wait for a major version (and new version of jQuery migrate) to deprecate them? |
@lpd-au Waiting for a major version wouldn't help in reducing usage of these shorthands. Besides, according to semver deprecations are free to land in minor releases. |
Just because they can, doesn't mean they always should. Especially the |
Nothing has broken because of this deprecation. It doesn't make sense to undeprecate the feature just to get rid of a warning in Migrate. You can either ignore the warning or override |
Undeprecate? What am I missing here... the issue is still open, marked for an unreleased milestone and isn't documented anywhere that I can find? |
I think it's safe to deprecate in the next version. It's not getting removed so no code will be broken. |
Is there any particular reason that these deprecations are not documented here: https://api.jquery.com/category/deprecated/deprecated-3.3/ |
@RinkAttendant6 See jquery/api.jquery.com#972. Someone needs to do the work to document it, we haven't gotten to it, yet. Contributions are welcome! |
As discussed (timestamp: 12:54:24) in the core meeting, we should deprecate
on
/trigger
event shorthand methods in a pre-4.0 minor release.EDIT by @mgol: I fixed the meeting link, it used to point to the latest day on IRC.
EDIT by @mgol: I fixed the meeting link again, it stopped working after the simplification of https://irc.jquery.org
The text was updated successfully, but these errors were encountered: