Live data from Hacker News

You might not need jQuery (2014)

youmightnotneedjquery.com

31–40 of 241 posts

Re: You might not need jQuery (2014)

#31

Earlier quoted context omitted.

> Hidden complexity you don't control is the most expensive kind I think. That's called encapsulation. :) Seriously, encapsulating complexity is the foundation of most programming paradigms.

Actually, it's called abstraction, as a technical point.

Good point. This is what I was referring to:

https://en.wikipedia.org/wiki/Encapsulation_(computer_progra...

Re: You might not need jQuery (2014)

#32

Earlier quoted context omitted.

Worth noting is that at least in the animation case, the non-jQuery (CSS) version should perform better than the jQuery version

Are you sure? AFAIR, jQuery has used native (hardware-accelerated) CSS transforms since 2014.

At least in the example on this page, it performs .fadeOut() by changing the opacity via JavaScript instead of using the CSS transition property. You can verify by inspecting the DOM

https://api.jquery.com/fadeOut/

Edit: I just realized you said "transforms". Transforms are a separate question from transitions. CSS transforms are concerned with giving an element a different size, rotation, and/or position. Transitions are concerned with changing any given CSS property gradually over time (including potentially transforms). I think you're right that jQuery started using CSS transforms, but it does not appear to use CSS transitions.

Re: You might not need jQuery (2014)

#33

It's ironic that there's probably no bigger sales pitch for jQuery than this site. In every single example, the jQuery version is basically one or two lines of code, versus 10-15 lines for the alternative. (and the jQ version seems significantly easier on the eyes as well.) Also, jQuery supports promises and has for quite a while. This page hasn't aged well. I've come full circle and am now using jQuery again.

I would prefer web developers accepted they need to write a few hundred lines of 'ugly' vanilla JS to drive their website than they include a 30KB library that they only really use 0.2KB of.

On the web, user experience should really be a higher priority than developer experience.

Re: You might not need jQuery (2014)

#34

Earlier quoted context omitted.

Are you sure? AFAIR, jQuery has used native (hardware-accelerated) CSS transforms since 2014.

At least in the example on this page, it performs .fadeOut() by changing the opacity via JavaScript instead of using the CSS transition property. You can verify by inspecting the DOM https://api.jquery.com/fadeOut/ Edit: I just realized you said "transforms". Transforms are a separate question from transitions . CSS transforms are concerned with giving an element a different size, rotation, and/or position. Transitio…

[deleted]

Re: You might not need jQuery (2014)

#35

It's ironic that there's probably no bigger sales pitch for jQuery than this site. In every single example, the jQuery version is basically one or two lines of code, versus 10-15 lines for the alternative. (and the jQ version seems significantly easier on the eyes as well.) Also, jQuery supports promises and has for quite a while. This page hasn't aged well. I've come full circle and am now using jQuery again.

I think a lot of the initial appeal around jQuery was that it made querying and manipulating the DOM simple. Much of its features have been replaced by broadly-available APIs like Document.querySelector and Element.classList. Loading the entirety of jQuery just to access some of the remaining features just means you're loading JavaScript that you aren't going to use. I miss relying on jQuery because it's familiar and…

We are underselling jquery a little bit. The browsers adopted jquery’s contribution of creating one of the most intuitive ways to deal with DOM/selection. It’s similar to how JSX is probably the most intuitive solution for templating/wiring/composing at the moment, also similar to how two-way binding was incredibly intuitive.

Browsers got to this point because jquery pushed for it.

Re: You might not need jQuery (2014)

#37

Now only if someone could combine the snippets on the right hand side in an easy-to-use library. Oh wait...

no no no... what we need to do is break them down so that each line is a separate library composed of a single function with its own independent dependency tree and test suite, then build another library out of that, all written in a language that compiles to javascript, and publish it to a proprietary package manager.

If we're really clever we can probably get it up to several megabytes, require three languages and have it run from an embedded C compiler written in Webassembly.

Of course, it will only work in Chrome but really who wants to waste time testing in browsers nobody even uses amirite?

Re: You might not need jQuery (2014)

#38

Earlier quoted context omitted.

I think a lot of the initial appeal around jQuery was that it made querying and manipulating the DOM simple. Much of its features have been replaced by broadly-available APIs like Document.querySelector and Element.classList. Loading the entirety of jQuery just to access some of the remaining features just means you're loading JavaScript that you aren't going to use. I miss relying on jQuery because it's familiar and…

I thought a big part of the initial sales pitch was not having to deal with cross-browser compatibility issues.

Maybe there was more than one big part!

Re: You might not need jQuery (2014)

#39
post #8

Earlier quoted context omitted.

This comment is a great example of what I call "lines of code mindset" which is form of tip of the iceberg mentality, where programmers optimize for simplicity only the code they see. Is saving 10-15 lines worth it if you need an 86.1 Kb vendor dependency? Hidden complexity you don't control is the most expensive kind I think.

> Hidden complexity you don't control is the most expensive kind I think. That's called encapsulation. :) Seriously, encapsulating complexity is the foundation of most programming paradigms.

In the real world, it turns out that code you didn't write can also have bugs or not behave as you expect it to, so the less of that there is, the better.

Encapsulation/abstraction should really be a tool of last resort. From experience, it doesn't actually help reduce complexity if overused, but just makes it hidden and more likely to surprise you when you're debugging.

Re: You might not need jQuery (2014)

#40

It's ironic that there's probably no bigger sales pitch for jQuery than this site. In every single example, the jQuery version is basically one or two lines of code, versus 10-15 lines for the alternative. (and the jQ version seems significantly easier on the eyes as well.) Also, jQuery supports promises and has for quite a while. This page hasn't aged well. I've come full circle and am now using jQuery again.

This is all very old javascript to be fair, the modern equivalents are as terse as jquery these days.
Post reply on HN