TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Why I'm still using jQuery

457 pointsby UkiahSmithalmost 6 years ago

46 comments

sgiftalmost 6 years ago
&gt; In my experience server-side generated templates lightly sprinkled with “progressive enhancement”-style JavaScript are still the best way to do that. Those apps are easier to develop, tend to be faster, tend to have fewer bugs, and your laptop’s fan won’t wake the neighbours.<p>Thanks for that part. Really. A heartfelt thank you. Every time I see another &quot;hey, I only want to show you text, but for some reason I thought using one of the modern js frameworks for it is a good idea&quot; pages I feel years older. Instead of showing me text using html they pack that text in js on the server (it usually exists in an html compatible form already), then they shove that JS down the connection, then my browser has to interpret the JS, so it can get the html, which it then has to interpret too. And then, finally, I see my text.<p>And because all of this is so slow we get techniques like &quot;server-side rendering&quot;. The first time I read about server-side rendering I didn&#x27;t understand what it was: so, you produce the html on the server. And send it to the client. Yes ..? What is the new part? Why is this something that people present as the next savior of the web?<p>This is some special kind of madness and I wonder when it will stop.
评论 #20022269 未加载
评论 #20022257 未加载
评论 #20022182 未加载
评论 #20023469 未加载
评论 #20021933 未加载
评论 #20022550 未加载
评论 #20025644 未加载
评论 #20024909 未加载
评论 #20024105 未加载
评论 #20021637 未加载
评论 #20022157 未加载
JaTochNietDanalmost 6 years ago
I&#x27;m heavily inclined to agree with this. In fact, only this weekend I was working on a very simple one page tool and from the get-go I decided to adopt this &quot;vanilla&quot; only approach, i.e no JS libraries really at all.<p>Pretty quickly I found myself wishing I had just used jQuery or at least some other library to make stuff easier and get things done faster. When I finally got it completed in the end I wasn&#x27;t sure why I bothered to struggle and waste so much time instead of just including jQuery and making things a bunch easier and less verbose. Sure, there may be other libraries worth using instead but the point against the &quot;vanilla JS is all you need&quot; argument.<p>I actually found the cited website in this post <a href="http:&#x2F;&#x2F;youmightnotneedjquery.com" rel="nofollow">http:&#x2F;&#x2F;youmightnotneedjquery.com</a> to be so strange as examples of why you may not need jQuery that it may be satire. I was surprised to find out that it was not satire. So I actually forked it and created <a href="https:&#x2F;&#x2F;youmightneedjquery.com" rel="nofollow">https:&#x2F;&#x2F;youmightneedjquery.com</a>, on which I may change some text in the future. It may not load for you yet as the DNS propagates.<p>You can find the fork on my Github account here: <a href="https:&#x2F;&#x2F;github.com&#x2F;JaTochNietDan&#x2F;youmightnotneedjquery" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;JaTochNietDan&#x2F;youmightnotneedjquery</a><p>I&#x27;ll make some changes later to show the satirical nature of it.
评论 #20023960 未加载
评论 #20021604 未加载
评论 #20021505 未加载
评论 #20022303 未加载
评论 #20021440 未加载
评论 #20021834 未加载
评论 #20021621 未加载
pier25almost 6 years ago
To give you an idea where I come from... I started doing front end in the late 90s, and for the past 5 or so years I&#x27;ve been mostly doing SPAs with Vue, React, Inferno, and Angular.<p>I&#x27;m done with SPAs and the whole modern front end workflow. If there was a solid benefit to a SPA it would make sense to endure all the complex development, ever changing ecosystem, etc, but in the vast majority of cases there is no benefit. Users don&#x27;t care about SPAs, some of the most successful biggest websites are not SPAs (Amazon, Ebay, Wikipedia, etc).<p>A static site generator like Jekyll with some sprinkled JS offers a much better experience. When that is not enough a good old server side rendered app with sprinkled JS is the next step I will consider.<p>There are some perfectly valid use cases for SPAs but those are rare.<p>And don&#x27;t get me started on libraries&#x2F;frameworks figuring it out as they go along. jQuery has had a stable API and methodology like forever. React has made major changes in only 5 years. From createElement, to JSX, to classes, to stateless components, to hooks, and only god knows what they will come up with next year.
评论 #20025023 未加载
评论 #20024640 未加载
bedersalmost 6 years ago
I&#x27;d like to introduce a new measure: Expected Complexity (EC)<p>Possible values: --&gt; Static webpage --&gt; There&#x27;s a Form! --&gt; I can click things and the URL doesn&#x27;t change! --&gt; I spend a few minutes on this site and click a few things --&gt; I spent a couple hours on this site and click lots of things --&gt; My office hours are spent clicking on things on this site!<p>How to determine at the start of development what EC value will be reached: Using a crystal ball (as usual)<p>Pick your technology according to the value of EC.<p>There&#x27;s a good chance that (= :jQuery (choose-tech [&quot;There&#x27;s a Form!&quot;, &quot;I can click things and the URL doesn&#x27;t change!&quot;, &quot;I spend a few minutes on this site and click a few things&quot;])<p>is `true` and that&#x27;s ok.
ehntoalmost 6 years ago
The given example of element.nextSibling is a great example of what jQuery gets wrong. In jQuery, that&#x27;s going to be $(el).next();<p>On first encountering $(el).next(), you need to answer a bunch of questions. Next what? Why is this a function and not a property of the object? Why not call it getNextSibling? What the hell is $() doing?<p>element.nextSibling is very clear. It&#x27;s the next sibling of the element. It&#x27;s idiomatic javascript, and it follows a good naming convention, which is a skill that is language agnostic.<p>The author is also conflating their time learning as a pro for jQuery. Had they learned vanilla javascript first, their point about not knowing which nextSibling to use would be moot. What they are referring to here is an idiosyncrasy, and jQuery is jam packed with them. The difference is they have learned them already.<p>If you learn jQuery today, you&#x27;re not learning core JavaScript, and considering the trajectory of web technologies you&#x27;ll be doing yourself a disservice not to use that learning time on actual JavaScript that you could use in future tools. jQuery isn&#x27;t a bad choice if you know it already, but if you are a new developer do yourself a favor and learn the foundation it&#x27;s built on first.
评论 #20022184 未加载
评论 #20022185 未加载
评论 #20021876 未加载
zaroalmost 6 years ago
I didn&#x27;t know about <a href="http:&#x2F;&#x2F;youmightnotneedjquery.com&#x2F;" rel="nofollow">http:&#x2F;&#x2F;youmightnotneedjquery.com&#x2F;</a> , but to me it seems very convincing that I need jQuery :)
评论 #20021482 未加载
评论 #20021689 未加载
评论 #20021619 未加载
drikerfalmost 6 years ago
Sure. But as always. It depends. If you&#x27;re writing a highly interactive app and your jQuery script starts containing a lot of view state, eventually you&#x27;ll go mad and probably duplicate a lot of logic on server and client too.<p>Seeing your app as a function of a data structure&#x2F;state is then much simpler. Although it will require a bit more thought initially. App = f(s).<p>Again, it depends. If you&#x27;re writing static sites and sprinkles will stay sprinkles, jQuery will probably be a solid choice.
评论 #20021591 未加载
评论 #20021544 未加载
JanStalmost 6 years ago
If JQuery is all you need to get the job done, go for it. It&#x27;s still fast, simple and easy to develop.<p>If you need state management, build a very complex app, etc. ... don&#x27;t.
评论 #20021462 未加载
评论 #20021454 未加载
评论 #20021507 未加载
geekamongusalmost 6 years ago
As someone who does application security assessments for a living, the biggest problem with jQuery is the lingering, outdated, vulnerable versions that are pervasive (1.x and 2.x in particular) in so many applications. I don&#x27;t care if you decide to use jQuery or not, just have a plan to maintain it and be able to update it without breaking everything, should the need arise.<p>&#x2F;preaching
评论 #20022000 未加载
评论 #20021593 未加载
评论 #20021971 未加载
edanmalmost 6 years ago
&gt; Pages like You might not need jQuery try to sell the idea that it’s easy to ditch jQuery[...]<p>I wasn&#x27;t aware of <a href="http:&#x2F;&#x2F;youmightnotneedjquery.com&#x2F;" rel="nofollow">http:&#x2F;&#x2F;youmightnotneedjquery.com&#x2F;</a>, but that&#x27;s an inaccurate summary of what the website tries to do and really does it a disservice.<p>It very specifically says, <i>in the first sentence on the site</i>, that you should use jQuery for regular development - it&#x27;s specifically talking about people developing <i>libraries</i>, and encouraging them to not force other people to load jQuery as an extra dependency, which is a very reasonable position. And I don&#x27;t think it&#x27;s trying to sell how easy plain JS is, as much as just giving translation code from common jQuery code to plain code, so that if you want to go that route, it&#x27;ll be easier to do so!<p>Here, I&#x27;ll just quote the first text on the page (emphasis mine):<p>&quot;jQuery and its cousins are great, <i>and by all means use them if it makes it easier to develop your application.</i><p>If you&#x27;re developing a library on the other hand, please take a moment to consider if you actually need jQuery as a dependency. Maybe you can include a few lines of utility code, and forgot the requirement. If you&#x27;re only targeting more modern browsers, you might not need anything more than what the browser ships with.&quot;
Aaron-goshinealmost 6 years ago
Fist let me say this thread has turned out to be possible the most important thread in regards to modern web development.<p>Single page Applications (SPA) and frame works that are used to develop such applications are over used which have led to a whole host of problems in the software engineering industry, I truly believe that if you are building software solutions 90% percent of the time you will be building them to solve business problems, so that should be of paramount importance not necessarily the latest shines concept and tools, especially unproven tools.<p>A very high percentage of the developers you will interview will be using front end frame work such as Reactjs, Anuglar, VueJs ... etc as a substitute for truly understanding the the native technologies and standards support by various user agents.<p>The consequences of this is usually very expensive for business while resulting in software products that are convoluted, complex and unstable; I have seen this too many times.<p>The JavaScript eco system at the moment is littered with these kind problems, pseudo stars developers who want to re invent the wheel (without first understanding the existing mechanics), not only is reinventing the wheel already an idea that has been frowned upon for thousands of years, in the context of software development most of the times it turns out to be a much buggier and less efficient solution.<p>I have encountered SPAs that have been built out to be so complicated and convoluted to say the least; in order to support server side rendering, hot module reloading, dynamic DOM refresh, Virtual DOM… etc. speaking as if these concepts are some holy gifts from the gods, and when you ask the most fundamental question what are the business values behind all of these concepts, there are no good answers.
sandreasalmost 6 years ago
I&#x27;m a bit sceptical about this article... I understand the point... jQuery is a nice place to get started for beginners and see how things have been done in the past and I also HATE the boilerplate with most modern JavaScript-Frameworks, but<p>&gt; I want to build webpages that are fast<p>I don&#x27;t think that jQuery is fast... Especially the fact, that jQuery hooks in every event handler to control the possibility to remove all Event handlers is something that is slowing down every app... event if jQuery is hardly used.<p>&gt; use the simplest feasible code<p>I don&#x27;t think that code is simple, when it is ONE single function that takes nearly every type as argument with different outcome...<p>And I don&#x27;t like that developers could use this article as a justification... especially while modern frameworks like vue.js can also be used without setting up a webpack project...<p>But: If you read between the lines, there is something to learn ;)
评论 #20115398 未加载
cdubzzzalmost 6 years ago
The thing that really got me to start thinking twice about jQuery, much more than the youmightnotneed... website, was this performance test for selectors —<p><a href="https:&#x2F;&#x2F;jsperf.com&#x2F;getelementbyid-vs-queryselector&#x2F;25" rel="nofollow">https:&#x2F;&#x2F;jsperf.com&#x2F;getelementbyid-vs-queryselector&#x2F;25</a>
评论 #20021616 未加载
评论 #20024313 未加载
Raphmediaalmost 6 years ago
I&#x27;ve been doing front-end for years and still use jQuery for almost 90% of my projects. It&#x27;s not because I&#x27;m resistant to change, I&#x27;ve done my share of SPA style projects.<p>Simply said, jQuery is still the best plug-n-play solution for most small projects.<p>The numbers are not against jQuery. There&#x27;s no real gains to skipping it. At 27.77 KB (Minified and Zopflinated file size) it&#x27;s not as if it&#x27;s weighting down your pages. On the rare occasions I actually come across something done faster in raw JavaScript (often because jQuery has some heavier polyfills), I simply use the raw JavaScript in my jQuery project.
thrower123almost 6 years ago
If it&#x27;s not broke, don&#x27;t change it. I could write more, but I&#x27;d just be echoing the post&#x27;s points.<p>I think the biggest win would be avoiding all the insane complexity of a modern npm&#x2F;webpack JS development experience.
Existenceblinksalmost 6 years ago
Javascript libraries ecosystem in post jquery era is also inefficient.<p>More duplicated efforts on making reusable uis because they (React&#x2F;Vue&#x2F;Svelte&#x2F;Elm&#x2F;Ember etc) don&#x27;t mean to integrate well with each other. Mostly they live their own world. Nothing integrates well with server rendering approach because most of them are based on virtual dom or compiler, vm that takes over the whole ui containers.<p>When you change a frontend language&#x2F;lib&#x2F;framework, your design system also need to change. All of your branded ui components need to be reinvented although some people just wrap libs such as Sortablejs, Select2 with their favorite js thing.<p>I&#x27;ve experiment Phoenix LiveView with a bunch of mentioned js lib&#x2F;framework&#x2F;language (above), nothing really integrates well for production uses. Vanilla js is still best bet for working with server-side rendered html (Unpolyjs or Stimulusjs is nice, but it only serves small purposes)<p>I hope there would be more js that works with good old html that you are already rendering.
degobahalmost 6 years ago
&gt; Pages like &quot;You might not need jQuery&quot; try to sell the idea that it’s easy to ditch jQuery. ... good reasons to not use jQuery: if you’re writing code that you want to be re-used by others...<p>Literally the first thing youmightnotneedjquery.com says is:<p>&gt; jQuery and its cousins are great, and by all means use them if it makes it easier to develop your application.<p>&gt; If you&#x27;re developing a library on the other hand, please take a moment to consider if you actually need jQuery as a dependency.
Asmod4nalmost 6 years ago
When you are done designing your Webpage, disable JavaScript, disable CSS (if your browser supports that) and check that you are still able to grasp what you want to present your visitors.<p>If you then don&#x27;t find the relevant information in the first second, congratulations, you just made a page which is useless to people with old Screen-readers.<p>I may be old fashioned in this regard, but i only see JS as a Add-on to the text you want to get out and only use it to add functionality which would be impossible with html and css alone. e.G. to give a hint when there are new articles to read, or when a article has changed.<p>Comment sections for example don&#x27;t require JS at all, but you can use JS to make it needless to reload the page after you send that HTML Form.
评论 #20022833 未加载
settsualmost 6 years ago
I’d be curious to see how many people have a cached copy of jQuery from one of the popular CDNs and what the overall real world effects are of that.<p>(That got me thinking of another potentially interesting analysis&#x2F;discussion about the distribution of jQuery versions being used…)
zackbloomalmost 6 years ago
I&#x27;m one of the original creators of You Might Not Need jQuery. Most of the examples still date back to 2014, with modern JS they get much simpler and shorter (the fetch API and async&#x2F;await help tremendously in the first example cited).
评论 #20024310 未加载
Chazprimealmost 6 years ago
I’m pretty much in agreement with this, to a point. jQuery is a reliable and fast way to make a age do just about anything, except maintaining state.<p>The <i></i>KISS<i></i> principle is practically unheard of in web development lately - I see teams using more “hip” technologies like React or Angular for simple sites, but then the complexity of the app increases considerably for not that much in the way of gains. Sometimes simpler really is better
cptrp2101almost 6 years ago
I think, as with anything else, it&#x27;s important we understand the tools we are using. I started with jQuery and the problem was (like many others) I learned it before I actually learned javascript. I&#x27;ve since backtracked and dug into vanilla JS so I can have a better understanding of what my code does.<p>Since then, I haven&#x27;t found a situation where I miss jQuery. However, I don&#x27;t damn anyone who uses it (beyond jokey arguments with the wordpress dev on my team).<p>It seems like this opinion won&#x27;t fit in well here, but at this point I find vanilla more than enough for anything where Vue or React will be overkill. However, I&#x27;m obviously biased as a front-end app dev and am open to seeing what other people have to say.<p>I&#x27;m not sure what to think about the server side vs. client side comments in the article since that fall outside my area of knowledge.
评论 #20022360 未加载
fareeshalmost 6 years ago
Is there a plan (or is it possible) for jQuery to look at going with some kind of modular approach where you can just import the stuff that you &#x2F; your plugins want?<p>I know there are libraries that claim to have 100% parity with jQuery&#x27;s selector library. Are there any ones that are making this claim reliably?
评论 #20021712 未加载
nickjjalmost 6 years ago
I still use jquery too and it doesn&#x27;t have to be a tangled mess of insanity nowadays.<p>Webpack + ES6 modules + jquery is a reasonable option IMO if you like the idea of server rendered templates with sprinkles of Javascript.<p>Plus, with the way things are heading with certain web frameworks (like Phoenix), you can do really interesting things like push the diffs of your server rendered templates over a websocket channel without having to write any user land Javascript yourself, and on the initial page load it just gets served without Javascript using the same templates. It&#x27;s like the best of both worlds (super fast feeling apps, SEO just works and you don&#x27;t have to duplicate templates and logic on both the client and server).
dsenkusalmost 6 years ago
convenience is the primary reason I still sometimes use jQuery. Sure dropping one more dependency always seems rewarding, but jQuery is just a tool which when used properly saves a lot of time.
masswerkalmost 6 years ago
Something seldom considered while discussing the use of libraries and frameworks: green computing.<p>Mind that you&#x27;re multiplying any overhead thousandfold or even millionfold when transferring the overhead to each client connecting to the service (including several instances of network infrastructure). So,&quot;how much effort it can be to use vanilla JS&quot;, – it may be well worth the extra effort, once, on a single side of the communication chain.
评论 #20022368 未加载
DoctorPenguinalmost 6 years ago
I would argue that the comfort of using jQuery comes at the cost of speed and obfuscation. I stopped using jQuery about 2 years ago and for the most part had no problems whatsoever even when I was forced to support IE9. Also I found that searching <a href="http:&#x2F;&#x2F;youmightnotneedjquery.com&#x2F;" rel="nofollow">http:&#x2F;&#x2F;youmightnotneedjquery.com&#x2F;</a> helps a lot when deciding how to implement certain features.
drinchevalmost 6 years ago
Hardest part to get rid of jQuery was the $.ajax function. Happily now, we can all use the fetch API with some extra polyfills, but pretty much that&#x27;s it.<p>`el.insertAdjacentElement`, really? Yeah if you carry jQuery thinking with you, you will probably want to translate the code literally and find substitute for everything. No... You can just use to recreate the part of the DOM that needs to be updated and replace it. It&#x27;s faster to write and easier to read.<p>Anyway most of the arguments are not considering, vanilla JS + webpack &#x2F; babel es6 + npm packages. In a world where side-effects are not well accepted anymore using jQuery is nightmare to maintain.<p>What&#x27;s this fuzz about btw, I thought this argument was over?
losvediralmost 6 years ago
I&#x27;ve seen a few apps that began as vanilla JS or jQuery updated to use react as the requirements grew and the &quot;simple&quot; JS started crumbling under its own weight. So I&#x27;m sympathetic to the idea of just starting with a framework from the get-go.<p>That&#x27;s why I&#x27;m excited to see how Phoenix&#x27;s LiveView turns out. It gives the &quot;server side rendered, sprinkling of JS&quot; approach more room to go in. It won&#x27;t replace something like Google Maps, but there&#x27;s a whole class of applications that would previously be on the border of the decision between react and server side that can be pushed into server side.
jesusthatsgreatalmost 6 years ago
If it works for you and is easily maintained by whoever is looking after it, great.<p>In my experience, sooner or later you&#x27;re gonna want modern functionality &#x2F; user experience and you&#x27;re in for a world of pain trying to hack it together with jQuery.<p>These days I&#x27;d only use jQuery for sites where I&#x27;m the sole developer and the project won&#x27;t change much over time. Or for legacy projects where the cost of moving everything to an SPA wouldn&#x27;t be worth it.<p>If you&#x27;re not the only developer on a project and the project is liable to morph over time, jQuery will be a costly mistake.
viachalmost 6 years ago
Idk in regards of how better the code can be structured with React or Vue, but opening apps based in these frameworks makes similar effect to starting Monero miner locally.
thrownaway954almost 6 years ago
It&#x27;s a mature library that takes the pain out of cross browser compatibility (yes... you read that right, cross browser compatibility is still a thing in 2019) and the verboseness of using native JS (yes... you read THAT right, using native JS is verbose), so why wouldn&#x27;t you want to use it?<p>Oh and on more thing... If you&#x27;re not using jQuery but instead using native JS with polyfills... YOU ARE A MORON AND DOING IT WRONG and should just you jQuery.
评论 #20022787 未加载
gchamonlivealmost 6 years ago
I have had my share of grief with jquery, but I&#x27;m not quite sure it was jquerys fault or the tools built around it. Many a time I had to reimplement stuff like radio button exclusion when a pop-up would render an HTML string as is.<p>Did anyone have problems like that? What are the jquery limitations I should be aware of?<p>I am asking because I am mainly backend and infrastructure developer and feel like I have little experience with frontend tools
pizza_r0balmost 6 years ago
<i>one line of trivial jQuery code gets replaced with 10 lines of vanilla JS code!</i><p>Actually those 10 lines are replaced by the entire JQuery library.
droptablemainalmost 6 years ago
This is all fine and dandy; use what works for you. However, as many of us have learned when trying to aggressively optimize performance, execution time is generally much longer for jQuery than with vanilla JS. So if you&#x27;re after high PageSpeed scores, for example, jQuery is the damn devil (or at least one of them).
jb3689almost 6 years ago
I like the progressive enhancement approach using a small amount of JS, and I&#x27;m fine with jQuery. The thing is that I don&#x27;t _use_ very much of jQuery. Rather than pull in all of jQuery you could just define your own `get` and `post` to abstract the XHR verbosity. No need to pull in a giant library to do that
RyanShookalmost 6 years ago
Great reminder that old does not equal bad!
javinpaulalmost 6 years ago
You are not alone mate, I am also using jQuery in 2019 :-) It&#x27;s one of my favorite JavaScript libraries.
sedatkalmost 6 years ago
jQuery is an idiomatic DSL but far from intuitive (does “after” imply a DOM modifying action or just a selector?). So I find it okay that browsers have a verbose API as it makes it clearer. Bare DOM API is nowhere close to jQuery in terms of practicality though.
umanagealmost 6 years ago
This is pretty much the reason I still use jQuery too. Although JavaScript now offers much of the jQuery functionality as built-ins, the very concise syntax that jQuery offers is more convenient to use.
nkozyraalmost 6 years ago
I think the most compelling reason to keep JavaScript is &quot;it&#x27;s already there.&quot;<p>I see no reason to yank it out unless you&#x27;re already doing some front end refactoring
评论 #20021541 未加载
forgot-my-pwalmost 6 years ago
When you don&#x27;t have to support Internet Explorer, using ES6 (fetch) is nice enough. When you need to support IE, it&#x27;s best to use jQuery.
评论 #20024539 未加载
robm99xalmost 6 years ago
I’m still using jquery and bootstrap for mvp web app using, of all things, PHP and Slim Framework which surprisingly is not horrible.
qwerty456127almost 6 years ago
el.insertAdjacentElement(&#x27;afterend&#x27;, other) seems a way more intuitive than $(el).after(other). I don&#x27;t code JavaScript yet the meaning of the first is intuitively obvious to me while I can only know what the second form does because you&#x27;ve told me.
tempodoxalmost 6 years ago
So, what is a good jQuery replacement nowadays, for just XHR and a bit of CSS manipulation?
unfuncoalmost 6 years ago
&gt; Pages like You might not need jQuery try to sell the idea that it’s easy to ditch jQuery, but the very first example is a good reason to use jQuery: one line of trivial jQuery code gets replaced with 10 lines of vanilla JS code!<p>There&#x27;s no such thing as one line of jQuery, it&#x27;s 10K lines before you add your one line to do that one thing that 10 lines of vanilla JS code can do.
评论 #20022445 未加载