23
620hun
8y

Please tell me I'm not the only one who gets really annoyed when someone uses jQuery to do stuff that would take the same amount of pure JS. I think these days many people only use jQuery out of laziness, not because it's necessary. Why load an entire library to set CSS attributes and innerHTML? Yes, there was a time when it was very useful to have jQuery, but today we have querySelectorAll and all that. You can save plenty of kBs, load time and improve performance.

Next time you're about to load jQuery ask yourself: do I really need it? Chances are the answer will be no.

Comments
  • 13
    I use it mainly because i don't know wtf I'm doing when it comes to front end 😂😂
  • 0
    This problem is for many. And though I not perfect at JS I do agree that it's a bad trend people follow , jQuery seems to be the wand for them , what they don't understand is it's a whole fucking library. So until it is something huge I would try to use JS first.
  • 0
    I only use it when doing AJAX requests. Should i use something else for that?
  • 0
    @digli Yeah same here. Ajax.
  • 1
    @digli XMLHTTPRequest + parsing with JSON
    It's not even harder than using the jQuery-Ajax-Methods.

    http://w3schools.com/json/...

    I'm not very good in frontend-stuff, so...
  • 1
    @Anaeijon JSON is useful yes. But is it easier via JS ?
  • 0
    @EpIcInCoGnItO depends on what you want to do.
    I usually use ajax to load some objects from a server.
    Most backend languages feature some easy methods to convert objects to json and vice versa.
    It's usually easier than using XML.
  • 1
    @Anaeijon I use JSON encode with php to load stuff on page at interval.
  • 0
    I wrote my own ajax module. It's based on stuff that I found on SO and W3C School.
  • 2
    @EpIcInCoGnItO Thats exactly what I mean.
    Starting Xmlhttprequest from client (JS).
    Return JSON encoded Object from server.
    JSON.parse on client.
    Work with the object however you want.

    That's all you need for ajax.
  • 0
    No, we use jquery because vanilla has so many pitfalls that I don't want to even try it (undefined as string + null as another thing for example)
  • 0
    @Anaeijon I am not good with words yet as not a pro in JS. Will check the xmlhttprequest thing.
  • 0
    JSON is easy to handle mostly.

    Reason is there are many devs who have learned jQuery but don't know shit about pure JavaScript.
  • 0
    @alkuzad I still don't know who thought that "undefined" as string was a good idea. is it a string or not!
    and NaN != NaN probably but that's still is justified somewhat
  • 2
    @flag0 I second that one. js before jQuery is must
  • 1
    jquery wasn't needed when it was made, when it came out new kids started loading jquery and wrote
    $("#id").html ("neat")
    when they could have just did
    document.getElementById ("id").innerHTML='neat';

    and called it a day, jquery should only be used if you are working on effects other than that it's shorter to just use javascript even looping to find a class name in the old days was less bloat than using jquery. when it first came out I thought it was going to burn out but kids found it as a short cut and screwed us all
  • 0
    @jckimble I don't think jQuery should ever be used. Except maybe where you have to manipulate tons of DOM elements at once. Even then you could still use querySelectorAll, but chaining can get tricky. jQuery is good for chaining.
  • 0
    I only use it when working on themes that already include it. Anyway most front-end stuff requires it, like fancy selectboxes, sliders, datatables... yes you could write them from scratch, but it's not worth the time
  • 0
    and it's useful to handle compatibility with old browsers, for example to attach a onclick event listener there are 3 different ways, depending on the browser
  • 2
    This discussion is an eye opener for many
  • 0
    Yeah, it deals well with prehistoric browsers. But if you develop for the modern Web you don't usually have to tinker much (except for CSS prefixes I guess).

    @EpIcInCoGnItO Already more than what I was for
  • 1
    @620hun Great you brought this up.
Add Comment