1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Do we really need jQuery?

Discussion in 'jQuery' started by dreamw0rk, Jan 31, 2014.

  1. #1
    Hi guys,

    Pointing to this website http://youmightnotneedjquery.com/ i wonder, do we really need it? another ballast in our websites ...?

    What is your opinion?

    Thanks
     
    dreamw0rk, Jan 31, 2014 IP
  2. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #2
    Personally, I prefer using jQuery, simply because it's well documented, has a ton of ready-made plugins for improving UI and such, and create complicated interfaces, and it, usually, makes writing stuff easier, and less complicated/extensive. Yes, you need to implement the jQuery-libraries, but since you can make custom-versions of those, which have what you need, and no more, I don't really see the potential overhead as a big problem.
     
    PoPSiCLe, Jan 31, 2014 IP
  3. HuggyStudios

    HuggyStudios Well-Known Member

    Messages:
    724
    Likes Received:
    20
    Best Answers:
    26
    Trophy Points:
    165
    #3
    The question is what do you need to accomplish as to whether you need to use jQuery. If you only need to perform a very small task with JavaScript then loading a 240kb library isn't really required! If you want to build a complete application which uses JavaScript then jQuery comes into it's own as it provides many cross browser functions to enable you to write faster.

    @deathshadow will now come into this topic and tell you it's rubbish has no point etc but he's a purist.
     
    HuggyStudios, Feb 1, 2014 IP
  4. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,998
    Best Answers:
    253
    Trophy Points:
    515
    #4
    @HuggyStudios, you rang?

    It's fat, it's bloated, it's slow -- and 90% of it's codebase serves no legitimate purpose... for the handful of cool things it provides like it's CSS style selectors for grabbing onto elements, it's doped to the gills with crap that either has no business on a website in the first place (see 49.5% of the garbage people vomit up using it) or is CSS' job. (another 49.5%); many of it's more robust (and large) functions (fadein, slidein) being something you should be doing with a simple class swap and CSS, or not at all.

    Worse, it actively encourages people to not learn the underlying language, meaning most jQuery users don't know enough javascript to be able to make a sane decision as to if jQuery is saving them code or not; most of the times not.

    For the most part it seems like the vast majority of people using it are doing so for "gee ain't it neat" manure that does nothing more than make the page slower, less accessible, and harder to maintain. From image sliders (one of the biggest piles of crap on the web) to goof-assed inaccessible animated menus, to this whole "web application" GARBAGE that is pissing all over the Internet's functionality taking things like webmail and turning them into useless train wrecks of ineptitude, jQuery is a blight upon the Internet that needs to be stamped out sooner than later.

    Developers are dumber for it even EXISTING!

    If one were to use a library (NOT a 'framework') of simple functions or methods, taking just the useful parts and not trying to do this idiotic "daisy chain of methods" that results in jQ based code being needlessly and pointlessly cryptic, I'd be shocked if it was more than 16k of code UNCOMPRESSED. The rest of it? No point.
     
    deathshadow, Feb 1, 2014 IP
    HuggyStudios likes this.
  5. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,998
    Best Answers:
    253
    Trophy Points:
    515
    #5
    Oh, and as to that page, 90%+ of the non JQ code examples are fat bloated garbage, or bad usability. Admittedly they're based on how jQ does things, which is by default bad usability.

    Take the 'fadeIn' example... My JS for that looks like this (assuming we already have the 'element'):

    e.className = e.className.replace(/\bfaded\b/,'fadeIn');
    Code (markup):
    Though it does take a bit of CSS to function.

    .faded {
    	opacity:0;
    }
    
    .fadeIn {
    	opacity:1;
    	-webkit-transition:opacity 0.5s;
    	transition:opacity 0.5s;
    }
    Code (markup):
    Admittedly, you don't get the transition in IE9/lower, OH WELL. Better than wasting battery time on a scripted interval code. Again, simple class swap and CSS doing the heavy lifting.

    Some of them could also be coded more efficiently 'in context', something snippets cannot show.
     
    deathshadow, Feb 1, 2014 IP
  6. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,998
    Best Answers:
    253
    Trophy Points:
    515
    #6
    Oh, another example of crappy code, the addClass method... detecting classlist is a waste of time, and the non-classList version provides no checks for redundancy.

    Assumes n is the desired class, and e is the element

    if (!RegExp('\\b' + n + '\\b').test(this.e)) e.className += (e.className ? ' ' : '') + n;
    Code (markup):
    Classlist is cute, but by the time you figure out it even exists, you could probably have just run the non-classList version.

    ... and I'm ok with putting that into a function if you use it more than once -- the problem isn't with that part of jQ's functionality; it lies in the massive crap that has no business even being in the library, and it's idiotic attempt to change how javascript works with the illegible cryptic daisy chaining of methods.
     
    deathshadow, Feb 1, 2014 IP
  7. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,998
    Best Answers:
    253
    Trophy Points:
    515
    #7
    Oh, and you want some CLASSIC examples of what I mean by "pointless bloat" and "methods that have no business even EXISTING", look on that page at "parent", "remove", "offset parent", "offset", "matches", "getting text", "getting outer html", "getting html" (NOT that those three should be used... EVER), "getting attributes", "empty", "contains", "clone", "children" -- I could go on for a bit... do you SEE the farking herpaderp?!?

    ... and ALL of those idiotic "let's replicate existing functionality" methods exist JUST because of the stupid malfing herpaderp "we have to daisy chain EVERYTHING" garbage.
     
    deathshadow, Feb 1, 2014 IP