by tambourine_man · 5y ago · 0 comments
Oh yes. Everyday. Still love it.
>…Javascript document api via document.querySelector, and document.querySelectorAll
The jQuery API is still (and probably aways will be) far superior to the native DOM (terser, composable, more expressive, etc).
>…smaller footprint libraries like lodash
jQuery is ≈30k gziped and most likely already cached from CDN.
>…has fallen out of favor of more comprehensible state management inside of JS (like React Hooks, Redux...etc.)
Managing state is hard. There shouldn't be much of it in any single view. IMO, React doesn't bring much to the table in this regard while adding a lot of complexity and heft. Vue is a bit better, but still, I'd much rather use jQuery if given the choice.
If you're building something like Spotify/Slack, I can maybe see the need for virtual DOMs, etc. If you're sprinkling interactivity to your webpage, which is arguably what most of the web should be, jQuery is probably as good as it will ever get.
This part isn't so true in reality anymore, due to revised browser caching systems[1]. Doesn't mean you shouldn't use jQuery, just that part of the benefits of a centralized CDN are no longer a factor and it's a lot more sensible to self-host.
1: https://www.stefanjudis.com/notes/say-goodbye-to-resource-ca...
A single retina hero banner is larger than most JavaScript libraries/frameworks.
https://github.com/fabiospampinato/cash/blob/master/docs/par...
In the last five years, the release schedule has slowed, so there was a convergence onto fewer versions in the wild, but at the same time, users were visiting fewer sites that used CDN versions (and fewer sites in general.)
Unfortunately not. There is no benefit to leaving your critical files on anyone else’s infrastructure: https://csswizardry.com/2019/05/self-host-your-static-assets...
Back then we decided it's just better to self host. Less things can go wrong.
Strongly disagree with this. In any complex web application with a lot of components, specially ones where a lot of fixed components can live for a while, React is definitely a massive improvement over vanilla JS or something like Backbone which allows wild west.
Imagine state coming from sockets, rest APIs etc with updates being either pull or push. A user might do an action which changes the state in some other component, keeping track of the components gets hard if the state is distributed. Also, centrally managed state with things like Redux allows for good caching of API data which can make a SPA considerably fast.
While I love plain HTML pages which need little or no JS, a lot of applications are better as SPAs.
If you've 20+ mutually dependent inputs, maybe you need a better UI, not a complex state management framework.
If your browser is ultimately executing an untyped crazy dynamic language, is it worth trying to shoehorn types into it, only to later transpile it back? Not to mention JSX.
It all seems so crazy to me, but this ship has long sailed.
Nope. And it's why Svelte is something that I've been hard adopting because it looks the closest to old-school JS/CSS/HTML while still bringing some of the same capabilities over that I love from React and VueJS. It also runs without a VDOM or a constantly running event loop - both things are incredibly attractive to me.
Although it's not a perfect solution (nothing is) I would strongly suggest you checking into Svelte as it looks more like traditional web development vs. highly complex Webpack + TS + React + eslint + Babel etc etc-based development.
The ship hasn't sailed. Your instincts to be weary of such a complex, constantly re-invented toolchain to get traditional development tasks accomplished are a natural response to the craziness that these tools bring to the table.
I rather like Svelte.
But honesty requires that we recognize that Svelte also uses Webpack/Rollup + TS + Svelte etc etc.
I like the idea of Snowpack. But if A.svelte and B.svelte both use C.svelte, Snowpack has to do a lot of redundant work to provide A.js and B.js with Svelte.js and C.js all converted again and again from ts then baked into both A.js and B.js. That's a lot of server work and a lot of client work and a lot of network work.
So you still want a webpack or rollup or what have you to bundle and tree-shake and codesplit for production. I don't know why this irritates me more than running any of my other code through a compiler. But it always has.
Unfortunately it hasn't caught on, though it maybe be too early to call.
I can't think of a single framework that does this, (its neigh impossible, actually, it'll just lock up your browser)
Svelte is cool, but this statement needs some serious proof
Also, what‘s bad about typescript?
If 400 people are accessing 10,000 static pages, don't use any js at all.
But we've been doing projects with millions of pages way before React :)
Checkout Wikipedia, which, by the way, uses jQuery, of course. And PHP.
>Also, what‘s bad about typescript?
It tries to turn the very dynamic JavaScript into something it will never be and no amount of contortion can hide it. Unless it stops being a superset of JavaScript in the future, but I don't see that coming.
For when I’ve wanted to sprinkle interactivity, this is what I’ve turned to lately. It’s quite brilliant, and more declarative than most solutions.
But React is still necessary in my day to day job, as our web application is incredibly complicated in terms of feature set and customisation. They both have a place.
The jQuery API really is so well done. I stopped using jQuery, but implemented a simple script (jSugar.js) that exposes many basic jQuery things but is really just a wrapper for native DOM operations. It only operates on individual DOM nodes. Any looping should be done using your JS loop of choice (forEach, for loop, which, etc).
The script started out really small. I've slowly added more and more as I need more functionality for some projects.
https://gist.github.com/pseudosavant/b86eedd9960ade958d49447...
so... like jQuery?
I don't believe any major browser allows sites to share 3rd party caches anymore.
Previous HN discussion: https://news.ycombinator.com/item?id=24894135
edit: why the dowvotes? are we not allowed to share our experiences now?
I did the same as you; moved on to Vue and haven't looked back. My frontend code is so much cleaner and easier to debug. I've built a large library of components, so often times adding a new page only takes a couple hours re-using those instead of writing a bunch of new JQuery from scratch.
JQuery is great when I need to make (non-contentful) changes to the DOM. But I refuse to use it for managing the state of my app or putting content in UI components.
Also as others have mentioned caches are individually isolated for each domain now to prevent tracking/data leaks.
Heck, even Slack was built with jQuery the first time. Only after a while they migrated to react.