Live data from Hacker News

jQuery v4.0 Beta

blog.jquery.com

221–230 of 404 posts

Re: jQuery v4.0 Beta

#221

Earlier quoted context omitted.

A few years ago I dropped jQuery for plain vanilla js and I've never looked back. Native js has everything jQuery has, except for the pile of often poorly maintained half baked "plugins", that usually only do what they want to do and not much else. Yes, the vanilla selectors are more verbose, but any half decent code editor will make them just as fast to type. I don't mean to be penantic, but I don't really understan…

Some of those examples aren't really equivalent. If you use that vanilla js way to show/hide, it won't restore the display property to the value it was before using hiding. It will just shift it between display: "none" and display: "". If you need something to be a display: "inline-block", the vanilla js example will lose that and break your styling. You can modify the code to set the display property as inline-block…

Except you can do this:

```css .hide { display: none important!; } ```

```js function hide(el) { el.classList.add('hide'); } ```

Re: jQuery v4.0 Beta

#222
post #89
post #67

Earlier quoted context omitted.

One website that almost always gets mentioned when people talk about jQuery today is "You might not need jQuery" ( https://youmightnotneedjquery.com/ ). That site is the best ad for jQuery I've ever seen. For almost every task it describes, the jQuery code is shorter, cleaner, and more intuitive than the vanilla "modern" JS one. And that's after almost 20 years, and I don't know how many billions of dollars invested…

This is incredible and such a great ad for jQuery. It's almost as if the creator(s) built that site ironically. So many examples are way clearer and easier in jQuery, like this one: JQUERY: $(el).toggle(); IE8+: function toggle(el) { if (el.style.display == 'none') { el.style.display = ''; } else { el.style.display = 'none'; } } Gotta love that "modern" triple attribute repetition. From: https://youmightnotneedjquery…

IE8 is a bit of a straw man. We've dropped IE entirely when testing unless there's significant (1%+) usage for particular clients, but even the NHS in the UK has dropped IE11.

Edit: https://caniuse.com/?search=classlist.toggle and click Usage Relative.

Re: jQuery v4.0 Beta

#223
post #88

Earlier quoted context omitted.

I mean, duh? Of course doing something that I've done for a long time is going to be more simple to me than me fumbling/stumbling through something I haven't done much. What new insight are you providing me here?

Async await fetch lets you flatten your nested callback functions into simple procedural programming. It makes everything much easier to reason about, no more closures and such.

JQUERY:

  await $.post({
    url: '/my/url',
    data: data
  }).then(() => {});

VANILLA:

  await fetch('/my/url', {
   method: 'POST',
   headers: {
     'Content-Type': 'application/json'
   },
   body: JSON.stringify(data)
  }).then(() => {});

I know which one I still prefer.

Re: jQuery v4.0 Beta

#224
post #194

Earlier quoted context omitted.

> The DOM API is entirely functional based upon traversal of a lexically scoped mode wat DOM APIs have been, and still are, 90s-era OOP style with zero attempt at being functional, declarative, or composable. Even the newly developed API are usually stuck in the same mindset (see everything developed for web components)

The DOM is a big in memory object but the DOM APIs are entirely functional. Functional is not the same as declarative.

> DOM APIs are entirely functional.

(Almost) none of the DOM APIs are functional. They are literally `object.methodCall()`

Re: jQuery v4.0 Beta

#225
post #207

Earlier quoted context omitted.

For tables my favorite jQuery plug-in is: https://datatables.net/ Have a page with some tables? A few lines of jQuery and you have search sorting etc. It can be customized but defaults are fine. This is how abstractions and progressive enhancement should be done.

I’m not even sure what I used, it’s the same 5 lines I’ve used for years. Boom bang and on to the next problem. For every unicorn saas webapp $300k a year developers are writing there’s a thousand small pages. If you’re building a house you aren’t going to use a Swiss Army knife, but if you’re camping out for a couple of days you aren’t going to take a van full of power tools.

A couple.of well selected power tools are certainly helpful, however. A battery blower to start the fire, a small electric chainsaw for any wood cutting depending on the area and what you take in, and a portable fan if you're in a hot climate. Sometimes a couple of selected power tools are very helpful.

Re: jQuery v4.0 Beta

#226
post #89

Earlier quoted context omitted.

This is incredible and such a great ad for jQuery. It's almost as if the creator(s) built that site ironically. So many examples are way clearer and easier in jQuery, like this one: JQUERY: $(el).toggle(); IE8+: function toggle(el) { if (el.style.display == 'none') { el.style.display = ''; } else { el.style.display = 'none'; } } Gotta love that "modern" triple attribute repetition. From: https://youmightnotneedjquery…

> Gotta love that "modern" triple attribute repetition. You can golf it down a bit: el.style.display=el.style.display == 'none' ? '' : 'none';

Even though I can appreciate the elegance of your solution, I'd prefer the former for clarity.

Re: jQuery v4.0 Beta

#227
post #2

In a world where many of us are actively trying to remove the last vestiges of jQuery, who is actively developing using jQuery? Genuinely curious. I’ve found that most of what I went to jQuery before is baked in now. querySelectorAll being the most powerful.

I'm guessing most active development which people are actually consuming. Already mentioned is Wordpress, which is most of the web. There's probably tons of front-ends using old Bootstrap which also came with Jquery.

Greenfield projects might not be using Jquery, but is anyone actually using those? ;)

Re: jQuery v4.0 Beta

#228

Earlier quoted context omitted.

> you can have that with server-side rendering plus yes, we use PHP for this which is much simpler to grasp than JS-SSR

Nah, not simpler, nextjs is simpler then php to start working with. Also running & deploying nowadays is easier. PHP used to be easiest, but fell behind.

[deleted]

Re: jQuery v4.0 Beta

#229

Earlier quoted context omitted.

Wordpress devs are the plumbers of the tech industry. It’s not glamorous work but there’s a ton of money in it because so many people need them. If I ever decide to retire from latest and greatest hype cycle big tech startup world, I’ll go build Wordpress sites for honest coin and wrap up every day by 3pm.

The fact that Wordpress runs so much of the web sometimes wakes me in a cold sweat. If you're a dev worth their salt and knows proven engineering and design patterns, then Wordpress code is absolutely terrifying to look through.

See comments like yours do that for me. I will see you in the 30 meetings needed for the new form on the contact page.

Re: jQuery v4.0 Beta

#230
post #207

Earlier quoted context omitted.

Yesterday I wrote a custom page which dumped out a table for some investigation. I threw jquery and a tablesorter plug-in. Without JS you get the table, but with you can easily sort and filter. Took about 2 minutes to add the optional filter. The backend is bash of course.

For tables my favorite jQuery plug-in is: https://datatables.net/ Have a page with some tables? A few lines of jQuery and you have search sorting etc. It can be customized but defaults are fine. This is how abstractions and progressive enhancement should be done.

Big plus is, it also gives yo the option to export the tables to pdf and other file formats.
Post reply on HN