• SnowdenHeroOfOurTime@unilem.org
    link
    fedilink
    arrow-up
    1
    ·
    edit-2
    1 year ago

    What’s the difference

    Your code reads like it’s from 1992 mainly, which makes sense I guess, given that you still find jQuery better than modern vanilla js. jQuery was created as a way to account for browser support challenges but is now obsolete. Anyhow, if I read “getElementById” in recent js code I would assume something was weird about that code. It’s old hat and there is rarely a reason to use it.

    What is the right way is context dependent

    Precisely my point. Which is why I think it’s opinionated in a bad way to arbitrarily pick one of them as the defacto. I often had trouble with jQuery’s .hide() method because while it felt natural to use it, it often conflicted with what actually needed to happen for good UX.

    What you’re missing is that the hidden class can contain anything you want. Animations or whatever else. In other words, the idea that there is a “right” or “most common” way to hide an element is flawed at its core.

    • severien@lemmy.world
      link
      fedilink
      arrow-up
      1
      arrow-down
      1
      ·
      edit-2
      1 year ago

      Your code reads like it’s from 1992 mainly

      Lol. You write a lot of text to mask the fact there’s no good reason why getElementById should be bad. It’s the same groupthink as with the jQuery, you’re told it’s bad, so you just follow the crowd.

      jQuery was created as a way to account for browser support challenges

      That was one of the reasons. The other was that DOM API was and still is crap. There were many such libraries to abstract away browser differences back in late 00s (Dojo, script.aculo.us, Prototype.js, MooTools), and the main reason jQuery “won” was that it provided the nicest API.

      Which is why I think it’s opinionated in a bad way to arbitrarily pick one of them as the defacto.

      You’re missing the fact that jQuery does not prevent you from hiding the element in other ways. It’s just optimizing for the most common case, which is one of the principles of good API.

      What you’re missing is that the hidden class can contain anything you want. Animations or whatever else.

      Sure, and when I just want to … hide it, without any animations? Then this hidden class is boilerplate only.

      • SnowdenHeroOfOurTime@unilem.org
        link
        fedilink
        arrow-up
        1
        arrow-down
        1
        ·
        1 year ago

        I mean you’re coming across like more of an old man than I am and that’s saying a lot more than you know. For the first 2 years people shit talked jQuery I didn’t agree with them. And then I got the opportunity to work without it and it seriously took like 3 days to completely change my mind. And all my pages were I believe about 100KB lighter.

        jQuery is trash. And that doesn’t mean it wasn’t a great tool for its time. It’s truly obsolete now though. If you hate the native JavaScript stuff so much… I dunno maybe go work with Java or something?