0

However, the question on this site was closed, 14 years ago: When a task can be accomplished by either Javascript or CSS, is it better to use CSS? .

This all seems very fundamental, and not opinion based. JavaScript is made to modify styles/html, and not to re-implement them.

How is this not a good question? I can almost see how this is like comparing two languages (C++ / C#), but 1, CSS/JavaScript are clearly far more intertwined than regular languages. This seems to be more similar to https://stackoverflow.com/questions/609517/why-em-instead-of-px .

At the risk of getting this question immediately closed for having two question marks... if CSS vs JavaScript is not a good question for Software Engineering, is it a good question for any other site? It sure doesn't seem like a https://philosophy.stackexchange.com/ question, but what do I know...

I'd be very interested to hear a well reasoned answer as to why it's not a good fit.

3 Answers 3

4

It's not a good fit because we, as a community, have decided that we do not want to address choice questions.

The question is fundamentally a choice question - given an arbitrary, non-specific task that can be accomplished in both CSS or JavaScript, choose between implementing the solution in JavaScript or CSS. This falls well into the "product or service recommendations" (which includes recommending a programming language) or "what is the best way" questions (especially since it doesn't have specific, objective criteria for evaluating "best"), both of which are explicitly off-topic.

It may be possible to write a good question about this topic. Since JavaScript and CSS are intertwined, it may be possible to formulate a "best way" question that contains specific, objective, measurable criteria for evaluating alternatives, perhaps including a general approach for determining when to implement something in CSS versus JavaScript.

2
  • Thanks. It seems like the difference is JavaScript isn't competing with CSS. It was never intended to be a replacement. It seems less "which is better than the other", and more "Here's why we have JavaScript and how it can augment CSS/HTML". Is em vs px also a bad fit? Commented Dec 2, 2024 at 17:59
  • @yeerk The em vs px question is asked on Stack Overflow, so it follows their rules. If it was asked here first, I'd suspect it would be OK. The main emphasis is on why. Getting to why something is a good practice and in which situations it is or is not a good practice would usually be fine, as would questions about heuristics or approaches to evaluate tradeoffs to make a decision. These types of questions are usually broadly useful and applicable. Commented Dec 2, 2024 at 19:43
3

As far as I can see the question was asked 13 years ago, and closed ~10 years ago. All in all it got 5 answers, four times more upvotes than downvotes and was not deleted since then. That gives me the impression the question was actually not too badly perceived by our community.

Note "closed" was the state of the question at the time when I wrote the above paragraph. In between, the question was reopened again in Dec 2024, most probably because this meta question drawed more attention to it.

Thomas already explained why we usually do not answer such questions anymore - at least not today, where a question about a technology choice is often closed immediately as "off topic" - we have a predefined close reason for this. Still, this was not the literal reason for closage in 2014 - the close reason was "opinion-based".

It is not uncommon on this site to find sometimes questions which deal with a software engineering topic, but are likely to encourage a lot of opinionated answers, since there can obviously be no "right" answer. This sometimes turns out just after the question was answered a few times by people givening answers like

  • "In my opinion, I would use tech 1 for foo, and tech 2 for bar", and a second one

  • "I would also use tech 2 for foo under the circumstances xy, and a mixture of tech 1 and 2 under circumstance yz", and a third one

  • *"consider also to use tech 3", and a fourth one

  • "don't forget about the drawback when mixing tech 1 with 2 in case xyz"

This is the point where either a diamond mod or a group of community members will hopefully close the thread against further answers, because at that point additional answers are unlikely to produce any real insights any more. Still, these Q&As can stay here for years afterwards.

The question in stake is IMHO one of this kind, and there is nothing wrong when it is kept as a closed question (or now as a reopened question). When closing and reopening of an old question happens several times, moderators may put a historical lock on it.

0

I think 15 years ago the question would be a legitimate technical question, "Some crazy people are changing styles using javascript, but are there technical problems with it?"

Now with javascript being used for styles in loads of popular frameworks as a standard practice the question comes across as more of a "There are two well established ways for doing styles.... let's argue about which is best!"

I guess you could rephrase "What is the most performant way to do dynamic styles? Css or Javascript?" But then it would be a hard question requiring actual testing, or a request for 3rd party info

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.