9 ms·
Also, jQuery is awesome. People have been in love with the overly complex and fancy javascript frameworks for the last 15 years or so. But jQuery doing dynamic
by ecshafer 3y ago
Also, jQuery is awesome.
People have been in love with the overly complex and fancy javascript frameworks for the last 15 years or so. But jQuery doing dynamic binding to dynamically generated forms for some error states and maybe an ajax calls is literally all the javascript you need in 99% of web pages and the rest is overkill.
The industry is going to move away from the complexities to React and towards more of this simplicity with htmx, phoenix live view, ruby on rails turbo, and yes just jQuery.
- bufferoverflow 3y agojQuery is not awesome. It was awesome 15 years ago. Now it's completely outdated. It's very hard to reason about DOM that can be manually changed by any random piece of code. That's why declarative solutions like React/Vue/Svelte are so much better.
- rjbwork 3y ago>It's very hard to reason about DOM I don't mean to be overly snarky here, but as someone who's just totally out of their depth in modern web UI - is that why people like these frameworks? Because they're very easy to reason about? I've generally found them to be mountains and mountains of boilerplate and spaghetti, but I really do not have a wide base of experience to pull from on this topic.
- auxfil 3y ago[dead]
- christophilus 3y agoThat's one of the reasons I like them, yes. I've done a lot of manual DOM manipulation, and a lot of jQuery. When you're building anything complex, it starts to become quite difficult to figure out why a particular piece of the DOM is behaving the way it is. It could be an overly aggressive selector that accidentally targeted it, or any number of things. Prior to React (and similar libraries), DOM manipulation was generally done in a mutating, effectful way. With React (and similar), if a thing is behaving strangely, I just need to go to the component that rendered said thing, and I can almost always find the problem.
- Capricorn2481 3y agoI started with Jquery, I learned React. I prefer React. React complexity is often conflated with things like Next JS or other SPA solutions. React was originally meant to be a library for building small components that you drop into an otherwise static websites. But people usually don't talk about React unless they're talking about whole sites being in React. For that reason, I think its complexity is exaggerated. More importantly, what the commenter is referring to is the fact that you are encouraged to write Jquery code that can break if you decide to move a div or change a class name. The workflow of CSS selectors is fine for small apps, but can lead to hard to track bugs down the road. It can be avoided if you make a lot of unique IDs. But otherwise you're screwed. There's no scoping. You technically have to read every piece of Jquery code before changing any other code, html, or css, because you could break half the site depending on what people were depending on. There's no IDE support telling you what is selecting what. Events are not colocated on the things they attach to, they could be anywhere. I can update a React component and be sure that the only places it affects are the places its rendered. And I can get type checking on every input going into a component. That's just way better to me. I still use JQuery at work, but I usually dread it. And people say JQuery is "smaller" but I would still prefer something like Svelte to Jquery if that's a concern. I can take or leave Vue, I don't really notice a huge difference between it and other component frameworks.
- treflop 3y agoI’m a big fan of React and jQuery but it sounds like you’re not using jQuery right. All my jQuery components were self contained and you just initialized them with $(‘[data-date-picker]’).datePicker(). It is pretty obvious to anyone looking at the code that if you remove “data-date-picker”, it stopped being a date picker.
- Capricorn2481 3y agoThat is true, but this is built-in to React and it's optional for JQuery. I am working on legacy projects a lot and nobody ever writes JQuery like this outside of famous libraries.
- erhaetherth 3y ago
- kccqzy 3y agoYes React is easy to reason about. In fact old versions of React were even easier to reason about than modern versions using hooks (`useState`). I used to use React and just React: no random npm packages, no Babel or any transpilation, no JSX, and it was pure joy compared to jQuery in a complex multi-step form. The jQuery code was in fact spaghetti.
- jmondi 3y agoFor your blog, jquery is totally fine and reasonable. Jquery for a web application? That is going to be way more of a headache. It all depends on what you’re trying to accomplish.
- marcosdumay 3y agoI guess the "easy to reason about" thing people keep saying is meant to tell you that the modern frameworks allow modularization. Personally, I do find their style of modularization abhorrent. As you said, it's full of boilerplate, it's also full of dependencies, and the worst sin in a software architecture: they don't enable you to specify a simple interface between modules. But they do solve the lack of structure you get when all the code talks to each other freely through the DOM.
- docmars 3y agoCreating a brand new Vue app using Vite as your build system (official) takes less than 2 minutes and you can immediately start using Vue by following its documentation and creating a well-organized web application with its friendly patterns and solutions to the most common pro-UX problems you could encounter in a web app. Give it a shot, it's stupid-easy, and that's not downplaying anything either.
- rjbwork 3y agoThis is pretty funny because the front end team at my company decided last year to migrate from Vue to React because Vue is too complicated and it's hard to find people who know it vs React. Impossible for me to get a read on this stuff. Such a clusterfuck of an ecosystem.
- docmars 3y agoYea there's certainly a lot of mixed opinions and learning curves involved to be sure. On the one hand, I love how many options there are to build web applications, but on the other, it really does feel fragmented and hiring front-end engineers is a huge gamble with all the different preferences involved because there is no true concept of "standards" everyone follows. Thankfully it's pretty easy to align a team with a little time and learning what everyone wants.
- scotty79 3y agoYou can make spaghetti with everything. But without framework spaghetti is even worse. People who make a mess out react do it because they try to use it as if it is jquery.
- genocidicbunny 3y ago> It's very hard to reason about DOM that can be manually changed by any random piece of code. I think the parents point is that many websites don't need to change all that much DOM manually, automatically, or in any fashion. And I would agree with them, that for when the only 'dynamic' part of your site is one or two simple forms, and maybe a little carousel of images, jQuery may be perfectly awesome.
- drschwabe 3y agoIt's good for quick things and prototyping cause you can always swap out those calls with native later. It's API is generally easier to remember/less typing that most native equivalents. You can also use its API serverside via Cheerio to do parsing & manipulation of html without a dom. edit: also its way more lightweight than React/Vue/Svelte i don't necessarily disagree you shouldn't reach for jQuery if you have a dynamic page (something like uhtml+preact signals would be good if you have fair bit of rendering logic going on) but I would say you should totally try seeing how far you can get with jQuery instead of Svelte/React/Vue on simple pages.
- zztop44 3y agoIs it really way more lightweight than Svelte? Svelte has more tooling (of course) but it ships no runtime and only sends the user the JS they actually need to interact with your page.
- drschwabe 3y agoWell, if you're talking SvelteKit then it requires a build step so yes, jQuery is way more lightweight. jQuery is also pure JS whereas Svelte is Typescript so it may be more difficult to debug/hack if your primarily JS coder.
- labster 3y agoDifferent use cases. A lot of the web only has only one or two interactive elements in a scope. The DOM being changed by any random piece of code is not a problem when all of the JavaScript fits on two screens. In fact, it’s a benefit here.
- williamcotton 3y agoThat is not why React became popular. We have to go back to the end of the server-side ORM era. ERB templates creating an LI element in a certain manner and jQuery creating the same element. So have fun keeping those DOM elements in sync! This and the ever expanding DOM APIs led to single page applications where all of the markup was generated by the client. Cue, oh fuck this is slow and oh fuck, page loads and SEO suffers, so then we see the emergence of virtual DOMs along with server-side Javascript, and we are now generating the same DOM elements with the same code on the front and back. Then everyone realized we are making these complex applications with an untyped language with lots of warts… Flow and Typescript emerge. Guess what? Spooky action at a distance continues with reducers, custom hooks, custom injected contexts, etc, etc.
- hsbauauvhabzb 3y agoI learnt jQuery and I would say ‘I could code in jquery, but not pure JavaScript’ - that’s since changed but I do still find foreach jQuery iteration by classname fairly elegant, in addition to $.get and $.post. I’m not saying that it’s good or bad, but maintenance may mean developers who don’t know or care for modern web don’t have to learn something new.
- Klonoar 3y agoNo, if you actually make modules with jQuery where it’s creating it’s own DOM tree, it’s no different from what React & Co are doing. Reasoning about the DOM structure has almost never been an issue in my almost 20 years of professionally doing this junk. The complexity has always been elsewhere.
- alternatex 3y agoAnd you're arguing the complexity that has to be somewhere should go in your custom built jQuery modules instead of components built with a well-known framework? I spent years maintaining front-end code built by devs who believe their way of doing things was better than what's popular in the industry and I disagree about jQuery entirely. jQuery is a low level tool and always ends up biting people as the project grows.
- Klonoar 3y ago> And you're arguing the complexity that has to be somewhere should go in your custom built jQuery modules instead of components built with a well-known framework? jQuery + the DOM are well known frameworks. ;P
- tipiirai 3y agoSecond to that: jQuery is awesome. Or more specifically: the idea that websites can be built with vanilla HTML, CSS, and _optional_ JS. jQuery embraces progressive enhancement and separation of concerns pattern, which is quite the opposite of how websites are built these days. Web development starts with 10+ React import statements for components, CSS, images, and whatnot. JavaScript is a must, not optional.
- p-e-w 3y agoOne website that almost always gets mentioned when people talk about jQuery today is "You might not need jQuery" (https://youmightnotneedjquery.com/ 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 into advancing JavaScript.
- tipiirai 3y agoIt's the jQuery API design. I often find myself creating functions like this one: export function $(query, root=document) { ... } jQuery acted as a role model for standard web committees. The argument for querySelector / querySelectorAll calls is literally mimicked from John Resig's groundbreaking API design.
- cxr 3y ago[flagged]
- tipiirai 3y agoAbsolutely yes. jQuery selector engine was developed before the official Selector API, which ended up being almost exactly the same. Except for a few exceptions which John wasn't too sure about when they asked for feedback: https://johnresig.com/blog/thoughts-on-queryselectorall/ https://johnresig.com/blog/thoughts-on-queryselectorall/
- rdedev 3y agoI'm not a web developer but sometimes I have to make a page with some JS functionality. jQuery saves me a lot of time in such cases
- esaym 3y ago>But jQuery doing dynamic binding to dynamically generated forms Do you have an example of that?
- DonHopkins 3y agoHold my beer! https://alive22-dev.turnaroundhealth.com/static/javascript/questionnaire.jquery.js https://alive22-dev.turnaroundhealth.com/static/javascript/q...
- ourmandave 3y agoMore that one line, doesn't count! =D
- DonHopkins 3y agoIt's one line when minimized! ;)
- cxr 3y ago[flagged]
- worthless-trash 3y agoI think your definitive comment above 'absolutely not' has tainted how people see your authoritatively spoken statements.
- deleted 3y ago[deleted]
- cxr 3y agoOkay?
- erhaetherth 3y agoIf you don't want to use a big framework, then you needn't use any library at all. Nearly everything in jQuery is 1 line of modern JS, no?
- pier25 3y agoOne line of jQuery can replace many lines of vanilla js.
- colordrops 3y agoYes, there isn't much reason to use jQuery these days other than keeping with the idioms of a legacy system.
- deleted 3y ago[deleted]
- troupo 3y agoNearly everything in jQuery is more concise, consistent and composable compared to modern JS APIs. As this site clearly shows: https://youmightnotneedjquery.com/ https://youmightnotneedjquery.com/
- deleted 3y ago[deleted]
- masklinn 3y ago> Nearly everything in jQuery is 1 line of modern JS, no? Since JavaScript never actually requires line breaks, yes. Otherwise, absolutely not. Modern web APIs remain highly statements-based, with little affordance for pipelining / cascading.
- krick 3y agoI won't dare to predict where industry "is going to move", since I'm not really a frontend developer, so what do I know anyway (and especially since it seems to switch directions every couple of years, and mostly being pulled in all directions simultaneously). But personally I still prefer to use stand-alone JS-scripts and libs included directly into the page, if I can. Mostly because I hate having to deal with complicated (and, importantly, rather slow) build process just for the sake of a couple of web-pages, when the real stuff is some totally invisible backend processing or maybe some sort of HTTP API to be used by other services. Also, honestly, I really just don't know what's the "correct" way to do things in 2024 on frontend, and I don't know where to even look for a guide, if I don't really want to spend next 6 months entirely in the pursuit of attaining "real" frontend-dev proficiency, but ultimately just to make working stuff, even if it doesn't quite follow the v2024 web-etiquette.
- palmfacehn 3y ago"Etiquette" implies there is some civilizing force. A system that allows us to coexist in peaceful, accessible sanity. Someone said of a profitable app/site I created with vanilla JS, "But this is looks like it is just a Bootstrap site" At this point, functionality be damned, customers expect a loading spinner. The norm is something that doesn't load on the first request. Sites don't paint the screen until 10 seconds later, because they are avoiding repaints. Maybe 10-20mb of JS is included in the typical app in this niche. Many totally fail on Firefox. Ambiguous user facing errors on a black screen, "An application client side error occurred" are par for the course.
- webworker 3y agoI keep saying this. At some point, some very smart people are going to figure out how expensive React is to build and maintain, and it’s going to change the conversation.
- falsandtru 3y agojQuery remains the best JSONP library. It can get data even when other libraries are blocked.
- rolisz 3y agoIf I understand this announcement correctly, they removed support for JSONP
- falsandtru 3y agoJust removed "Automatic" JSONP "promotion". JSONP is still available.
- patrickaljord 3y agojQuery is amazing, still remember the joy of using it 20 years ago. That being said, React, Vue and similar are just better IMO to build and maintain complex apps. Don't get me wrong, jQuery was the best thing at its time and I will always be grateful to its contributors, but today there are better alternatives. I think htmx is nice but not seeing it taking over other frameworks.
- linkjuice4all 3y agoDefinitely agree that the modern frameworks are better for complex stuff. Ideally there’s not really a middle ground - you’re either doing complex interactive “app-like” stuff with a framework or adding modest dynamic features to otherwise static content (e.g. static export of WordPress with some jQuery for your forms).
- throwaway2990 3y agolol react. Never seen a good react project. They all end up a mess.
- yashg 3y agoYup, jQuery is indeed awesome!
- holoduke 3y agoYou still need some kind of application framework. Jquery is just a low level utility. But higher level you need to maintain architecture. Specially in spa's
- hnfong 3y agoYou don't "need" an application framework. People have been building websites (even SPAs) before the 2010s and they didn't "need" these frameworks. Given what we know today, I'll grant you that in some cases people would want to use a framework, but it's hardly a necessity unless the context provides more specific requirements.
- agos 3y agoyou don't "need" a framework for backend development, too, but most people find it highly convenient
- holoduke 3y agoIts can be convenient to have some kind of reusable conponents. Like listviews wtih certain functionality. Same for routing. Caching etc.
- claytongulick 3y agoNative web components / custom elements work great for this.
- holoduke 3y agoSo you end up with an component framework.
- bdhcuidbebe 3y agoYou dont ”need” anything. But most people prefer some organization, familiarity and reusability, and not having to reinvent the wheel in every project they start.
- khasan222 3y agoI’ve been writing JavaScript for 15 years professionally, and I must say this comment seems to be made by someone not as familiar with the context here. Moving away from React and frameworks like it would require a radical rethinking of what we expect to do with web apps. Building something like google maps, google docs, figma, are definitely doable with some of these tools, but it is almost impossible to maintain. This comment truly ignore the context of why frameworks like react took off. Jquery is great if you need a slideshow on a page, and maybe just some tracking, and even then, I’ve recently opted to just use vanilla js, with things like webpack build targeting whatever versions I would need. JavaScript programming is complex because making great ux can be a non trivial task. Please excuse any typos, written on the phone
- heartbreak 3y agoHow many React apps actually have an interface approaching the complexity of Figma or even Facebook? No one is arguing that complex web applications don’t benefit from React and friends. It’s completely overkill for most of the web.
- anthonypasq 3y agowhy does everyone have this impression that people are using react to render a website that is 5 divs and some images, like where is this perception coming from? do you have any examples at all? any website that has any sort of meaningful functionality and communication with a server is mostly likely using some sort of framework.
- docmars 3y agoAgreed. There is a _lot_ of naivety around how these frameworks are perceived, from people who have never used them, or who come from different programming backgrounds (i.e. not frontend). It's amusing.
- hombre_fatal 3y agoYeah, there's this whole meme on HN where React competes with hand-writing the HTML of your three-page brochure website, a website virtually nobody is building.
- lucsky 3y agoNo, the "industry" is not going to move away from React (or Vue or Solid or Svelte), but idiots on HackerNews (and Reddit and Twitter and Mastodon, etc) might finally stop conflating web SITES and web APPS. One can dream.
- spillguard 3y agoFrom the guidelines: "Be kind. Don't be snarky. Converse curiously; don't cross-examine. Edit out swipes."
- lucsky 3y agoYou're right, this was 100% sent out of frustration and I probably shouldn't have. I still think that the level of nonsense in this comment section is of galactic proportion though.
- cphoover 3y agoAgreed...Another gripe... the amount of people on HN complaining that a web-app doesn't 'work without JS, when the number of user's who disable JS inside their browser is well under 1%. HN users don't even consider they are not in anyway typical web users.
- dagss 3y agoUnpoly too (very similar to htmx but the small difference makes it a lot more convenient I feel, I wonder why Unpoly isn't getting as much traction as htmx)
- docmars 3y agoOrganizing a large jQuery project is absolute hell though. I'll take modern frameworks like Vue any day. The ease of shipping a full-fledged app that feels easy to create and maintain began with Vue (and Svelte). React tries to achieve the same result, but if you don't use it perfectly right, you're in for hours and hours of headaches and non-solutions.
- pjmlp 3y agoFully agree, jQuery + Bootstrap + standard Web + SSR, and we're gold.
- silent_cal 3y agoI read that the JS fetch API makes jQuery obsolete, is that not true?