If when answering a question, if the answerer chooses jQuery in the Stack Snippet editor but jQuery is neither tagged on the question nor mentioned in the question text, I'd like to see it show a warning bar at the top or similar warning the answerer that jQuery-only answers to non-jQuery questions are not useful.
Don't prevent it, of course; the answerer may be offering an alternative in addition to a non-jQuery answer, or jQuery may be implied in other ways, but just a warning/reminder would be good.
3 Answers 3
As a user who only answers JavaScript questions, I don't particularly see this as such a prevalent issue.
Yes, I accept that this happens, but I wouldn't say it happens enough that the situation requires special handling by the system.
In my eyes, the best recourse in this situation is to leave a comment on any answer which provides a jQuery solution to a JavaScript tagged question, and politely explain to them that the question does not include jQuery as a tag. In all the times I've done this, I've seen largely positive responses from the answerer, either to delete their answer, or to update it with a non-jQuery solution as well.
If the case anyone feels so strongly about this, they could also downvote the answer, and if the question explicitly excludes jQuery, voting-to-delete.
-
4Agreed. This is what I thought the purpose of voting was for.Loktar– Loktar2014年09月21日 20:13:37 +00:00Commented Sep 21, 2014 at 20:13
-
3I don't know how we're having such massively different experiences. I also answer mostly JavaScript questions, and see this every day of the week.T.J. Crowder– T.J. Crowder2014年09月22日 07:09:39 +00:00Commented Sep 22, 2014 at 7:09
-
@T.J.Crowder: I wish I could explain that, but I can't :(.Matt– Matt2014年09月22日 08:05:12 +00:00Commented Sep 22, 2014 at 8:05
I agree wholeheartedly with this suggestion, despite the concerns raised in the comments, because it's a valid warning to a quite real problem on Stack Overflow. The warning should however be worded in such a way that it is open to the possibility that the answerer:
- Doesn't actually use jQuery and just selected it automatically
- The answerer is providing both a jQuery and a pure JavaScript solution
- That the answerer believes the question should have been tagged with the jQuery tag (in which case the answerer should be motivated to edit the question)
Addressing the various concerns that are raised:
Many JavaScript questions imply the use of jQuery implicitly, because many users hardly know the difference.
They know enough to know they are using jQuery, thus getting these questions tagged has to happen either way. A warning like this could actually decrease the number of jQuery questions lacking the jQuery tag.
The problem is that the question may post code that clearly uses jQuery (starts with
$(function(){//...
for example), but the question isn't about jQuery per-se so it's not tagged with jQuery. In that case a jQuery answer would be totally appropriate and tagging the question with jQuery would not be.
So, this already sounded odd, because the consensus has always seemed to me that all questions using jQuery should be tagged jQuery, except if the jQuery part could be taken out without a second thought. If you're describing that last case however then the answers shouldn't be using jQuery either, because they should be answering the actual question, not taking along any boiler code. If for example the user shows code like the following, asking why the variable txt
isn't getting changed
$("button#someId").on("click", function(){
var txt = $("input").val();
var parts = txt.split(",");
$.each(parts,function(partValue){
partValue = "not getting changed";
});
});
The answer should just ignore the boiler code and show code like
var txt = "a,b,c";
var parts = txt.split(",");
parts[1] = "not changed in txt";
console.log(txt, parts);
To address the core of the problem. And even this case the question should be tagged jQuery, because the user asking the question is perfectly fine with jQuery solutions, even though in this case there are none of course.
I'll admit, I'm guilty as charged, I've been one of those derelicts that posts jQuery answers to a Javascript questions...
But, like mason pointed out:
jQuery is such an established framework, that even if the question doesn't use jQuery, it probably makes sense for future people to see an answer that shows how to do it with jQuery (alongside a non-jQuery answer for the original poster). Because the answers aren't just for the original poster, but they're also for other people that come along in the future with similar questions.
Perhaps rather than discouraging jQuery answers to JavaScript questions we should be encouraging users who are offering a jQuery answer to post a Vanilla JS translation along with their jQuery answer.
Before you burn me at the stake as a heretic, there is at least one really good reason to do this...
People end up using jQuery as a crutch largely because they don't know how to do the thing in Vanilla JS. Showing them side by side how to do something in both is a great teaching mechanism.
Perhaps the Old Guard of JavaScript could start answering jQuery questions with Vanilla JS as well...
If you're really that into discouraging jQuery, show people how to do stuff without it.
-
1Pedantry: I'ts not Vanilla JS, it's Vanilla DOM. The language doesn't change depending on what API you're writing to.T.J. Crowder– T.J. Crowder2014年09月26日 16:59:16 +00:00Commented Sep 26, 2014 at 16:59
-
1@T.J.Crowder I called it Vanilla JS because the linked page is hilariousapaul– apaul2014年09月26日 17:00:43 +00:00Commented Sep 26, 2014 at 17:00
-
1I'm not at all interested in discouraging people from using jQuery. I use it and answer a lot of questions about it. And I have no problem at all with someone adding an adjunct to their main answer (which doesn't use jQuery) showing how you could solve the same problem using jQuery (e.g., for future readers, or even to encourage the OP to check out that nifty library they saw used...). My only desire is to stop people posting jQuery-only answers to non-jQuery questions. They aren't useful to the OP if the OP isn't using jQuery.T.J. Crowder– T.J. Crowder2014年09月26日 17:01:33 +00:00Commented Sep 26, 2014 at 17:01
-
1"I called it Vanilla JS because the linked page is hilarious" Ah, yes, yes it is. :-)T.J. Crowder– T.J. Crowder2014年09月26日 17:02:15 +00:00Commented Sep 26, 2014 at 17:02
-
1@T.J.Crowder I'm not trying to put words in your mouth, I just know that there are a lot of purists out there that get really fired up about this topic. Just trying to offer teaching as an alternative to grumbling.apaul– apaul2014年09月26日 17:05:47 +00:00Commented Sep 26, 2014 at 17:05
-
1Yeah, I've run into a few of those...purists...as well. :-)T.J. Crowder– T.J. Crowder2014年09月26日 17:27:16 +00:00Commented Sep 26, 2014 at 17:27
$(function(){//...
for example), but the question isn't about jquery per-se so it's not tagged withjquery
. In that case a jquery answer would be totally appropriate and tagging the question with jquery would not be.var elems = $("input")
but the question is about how to, say, parse text (the value of those inputs) into a number. It's not a jquery question, it's a question where the OP happens to use jquery.