News for hackers. Stuff that matters.
Re:jQuery 3.0 Released by emirb on Friday June 10, 2016 @06:44AM (#11875457)
Re:jQuery 3.0 Released by cyphar on Friday June 10, 2016 @07:04AM (#11875517)
To me, all of the JQuery examples are much nicer to read and write. Sure, you can use raw JS, but why copy annoying boilerplate? (I'm not a JS dev, so I don't have a dog in this fight).
Re:jQuery 3.0 Released by inopinatus on Friday June 10, 2016 @07:28AM (#11875599)
The authors of that page seem to be making their suggestions principally for library authors, to avoid an otherwise unnecessary dependency on jquery.
Re:jQuery 3.0 Released by andybak on Friday June 10, 2016 @08:59AM (#11876013)
That page does an excellent job of convincing me to carry on using jQuery.

  if (el.classList)
    el.classList.contains(className);
  else
    new RegExp('(^| )' + className + '( |$)', 'gi').test(el.className);
vs

  $(el).hasClass(className);
<shivers>
Re:jQuery 3.0 Released by oneeyedpigeon on Friday June 10, 2016 @09:59AM (#11876351)
I don't think anyone would suggest you write all of the first codeblock every time you want to check a class. You'd put it in a function and call that, much like jquery does.

The point is that this site explains how you do it because a) that's probably easier than trawling through the jquery source b) including this polyfill when you know you need it might save you from requiring all the rest of jquery.

Re:jQuery 3.0 Released by andybak on Friday June 10, 2016 @10:38AM (#11876641)
In that case I'd be much more likely to use a minimal jQuery replacement such as umbrella.js mentioned elsewhere here. That's 3k (vs about 28k for jQuery) so counters most of the 'bloat' objections with jQuery. I'm sure it will still irk some some purists on other grounds however.
Re:jQuery 3.0 Released by edgarvaldes on Friday June 10, 2016 @10:41AM (#11876661)
Yep, the use of RegExp is enough.
Re:jQuery 3.0 Released by Cyph0n on Friday June 10, 2016 @07:14AM (#11875549)
Is that comparison supposed to show that jQuery is bad or what exactly? Because it's clear that jQuery is much more concise in every single case.
Re:jQuery 3.0 Released by inopinatus on Friday June 10, 2016 @07:29AM (#11875602)
No. That site is giving helpful alternatives so that library authors can avoid having jquery as a dependency.
Re:jQuery 3.0 Released by Touche on Friday June 10, 2016 @08:14AM (#11875797)
They are just recreating jQuery, no?
Re:jQuery 3.0 Released by qiller on Friday June 10, 2016 @10:04AM (#11876392)
Greenspun's tenth rule of js apps?
Re:jQuery 3.0 Released by Drakim on Friday June 10, 2016 @08:23AM (#11875842)
You aren't recreating jQuery by using basic JavaScript syntax.
Re:jQuery 3.0 Released by leviathan on Friday June 10, 2016 @08:53AM (#11875988)
isn't JavaScript what jQuery is written with?
Re:jQuery 3.0 Released by Twirrim on Friday June 10, 2016 @10:04AM (#11876390)
Yes, but why drag in 30k of additional library unnecessarily?

Yes use jQuery if it's really providing benefit, but if you're only using it for a few things, you may be better off just doing in in plain javascript, even if it's a bit longer.

Every library you add has an overhead cost on the end user as they have to fetch it and process it. It's easy to lose track of that when you're developing and testing against local webservers or on computers vs mobile, but there is strong value in keeping things small and with as few unnecessary dependencies as possible :)

Re:jQuery 3.0 Released by Touche on Friday June 10, 2016 @09:21AM (#11876140)
Not sure if you read the page, but many of the examples are not "basic JavaScript syntax", the fadeIn approach is a function that attempts to replicate jQuery's, probably poorly.
Re:jQuery 3.0 Released by Drakim on Saturday June 11, 2016 @05:02AM (#11882744)
No, jQuery did not invent the concept of fading in. It doesn't even have a unique implementation of it, it just does a few CSS changes that you can easily do without jQuery to get the exact same result.

This is as ridiculous as having a "addition" module in jQuery and saying that people who do addition in JavaScript are just reinventing jQuery.

Wrapping jQuery around something simple (like fading in) does not make it into jQuery. If anything this just demonstrates who incredibly unknowledgeable people are about where jQuery ends and JavaScript begins.

Re:jQuery 3.0 Released by starquake on Friday June 10, 2016 @07:16AM (#11875556)
The reason the site exists is explained on the site itself.
Re:jQuery 3.0 Released by eng_monkey on Friday June 10, 2016 @07:01AM (#11875506)
A good example of why I will continue using jQuery for the time being.
Re:jQuery 3.0 Released by j1vms on Friday June 10, 2016 @09:58AM (#11876342)
Yes, but it's always good for us to remember that everything has a cost, and so does jQuery (memory footprint/new dependency/complexity). It's a conscious decision we should make on every project, and yes in most cases it would take 0.5s to make a decision in jQuery's favor. We should do so anyways, since it's good practice. Taking into account the presumed state of Moore's Law and all.
Re:jQuery 3.0 Released by mhd on Friday June 10, 2016 @07:21AM (#11875575)
I'm surprised that there's no youmightnotneedprintf.com
Re:jQuery 3.0 Released by jjnoakes on Friday June 10, 2016 @08:00AM (#11875726)
I'm surprised you are comparing jQuery (a non-trivial additional dependency with reasonable dependency-less alternatives) to printf (a small piece of a dependency you most likely pull in already with).
Re:jQuery 3.0 Released by mhd on Friday June 10, 2016 @09:06AM (#11876064)
One man's trivial is another man's bother. I consider 30k (less than some images or the rather popular fonts) to be quite trivial for most purposes, and if it gives me a nicer syntax for common operations, it's probably worth it.

On the other hand, I've seen actual backlash against printf implementations in libs and the bloat they're causing, never mind potential bugs [1].

So there you go.

[1]: https://www.fefe.de/dietlibc/FAQ.txt

Re:jQuery 3.0 Released by jjnoakes on Friday June 10, 2016 @09:18AM (#11876121)
I'm not advocating for or against jQuery or printf. I'm just pointing out that equating the two (in size, utility, or potential gains by avoiding them) doesn't make a lot of sense.

jQuery's ratio of size-versus-additional-utility is much larger than printf's, even more so if you consider typical use cases of each.

But it isn't even a fair comparison to begin with. How about comparing jQuery to libc. I'd still argue the ratio is in libc's favor, but no one would have written "I'm surprised that there's no youmightnotneedlibc.com".

Re:jQuery 3.0 Released by mhd on Friday June 10, 2016 @10:34AM (#11876620)
libc seems much more substantial, maybe we can split the difference and call it "youmightnodneedstdio.com", although that sounds much less pithy.

I still wouldn't be so sure about that ratio. The people decrying the printf family of functions are often targeting small statically linked binaries. Where a few kb shaved off might be a bigger chunk than 30kb are for your usual multi-megabyte front page of today's web.

Re:jQuery 3.0 Released by jjnoakes on Friday June 10, 2016 @02:20PM (#11878630)
People who target tiny static binaries are by far in the minority of libc users.
Re:jQuery 3.0 Released by arethuza on Friday June 10, 2016 @08:29AM (#11875875)
Isn't it more like comparing jQuery with libc?
Re:jQuery 3.0 Released by jjnoakes on Friday June 10, 2016 @08:53AM (#11875981)
It would have been if he said "I'm surprised that there's no youmightnotneedlibc.com".

As soon as you do that though (put the two on equal-ish grounds), you realize it doesn't make much sense and it might as well not have been written in the first place.

Re:jQuery 3.0 Released by mikegerwitz on Friday June 10, 2016 @08:44AM (#11875943)
libc would be more like the standard DOM specification.

printf is a part of the standard C library.

Re:jQuery 3.0 Released by Shengbo on Friday June 10, 2016 @07:22AM (#11875578)
I don't think it's a question of necessity, it's just more convenient and usually a lot less code than doing the same thing without it.