TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

What benefits can I hope to achieve by switching from jQuery to react?

4 点作者 pyeri12 个月前
I&#x27;m a freelance coder who builds small-medium apps and my front-end stack primarily consists of Bootstrap+jquery. This combo has never let me down until now even with all kinds of features, functionality and complexity thrown at it. I&#x27;ve built dashboards with line charts, puzzles and MCQs, grids and tabular components to edit data and there have never been any issues.<p>But when I keep hearing the discussions here and on other places in social media, they make me feel like I&#x27;m stuck in a very different century! There is no doubt that React is a well-known, popular and robust piece of software but one thing that dissuades me from getting into it is the whole monstrous npm system of components around it. It seems to be quite integrated with node when it comes to some react components like next, nuxt or whatever. Is it not possible to just like include react through CDN with `link` or `script` tags and still make good use of it?<p>More specifically, I want to know what can I hope to achieve if I migrate from jquery to react? I&#x27;m quite tied to the jquery way of things right from DOM manipulation to event handling to things like cloning and reusing HTML components in `&lt;div&gt;` blocks. Is there any established guide or path for folks like us to migrate from jquery and react? And to begin with, is this a good idea even?

6 条评论

throwaway3837512 个月前
&gt; but one thing that dissuades me from getting into it is the whole monstrous npm system of components around it.<p>You are not alone. It is very complicated, but a lot of people seem to get off on the complexity (for some unknown reason).<p>&gt; Is it not possible to just like include react through CDN with `link` or `script` tags and still make good use of it?<p>Not with React (as far as I know). But with Vue you can use it straight off a CDN.<p>Follow this guide through. It take about 15 minutes but it is entirely worth it!<p><a href="https:&#x2F;&#x2F;v2.vuejs.org&#x2F;v2&#x2F;guide&#x2F;#Getting-Started" rel="nofollow">https:&#x2F;&#x2F;v2.vuejs.org&#x2F;v2&#x2F;guide&#x2F;#Getting-Started</a><p>&gt; More specifically, I want to know what can I hope to achieve if I migrate from jquery to react?<p>You can build SPAs (which although not impossible to do in jQuery, is a lot harder). You can also be part of &quot;The React Gang&quot; and get more jobs.<p>&gt; And to begin with, is this a good idea even?<p>Not if jQuery is still working for you. If it ain&#x27;t broke, don&#x27;t fix it! :)
chipdart12 个月前
&gt; It seems to be quite integrated with node when it comes to some react components like next, nuxt or whatever.<p>I find Next.js to be a hot mess of a framework. Sure, it&#x27;s nice to have the whole convention by configuration thing to have routable pages and pass path parameters, but the way it mixes server-side rendering with everything ends up building up a gigantic mess of a JavaScript blob that blows up spectacularly when anything doesn&#x27;t quite work.<p>To put this in perspective, vanilla React is the epitome of simplicity when compared with Next.js. Truly awful stuff.<p>&gt; Is it not possible to just like include react through CDN with `link` or `script` tags and still make good use of it?<p>If by &quot;include react&quot; you mean serve the JavaScript bundle through a static file server, technically it is. However, you&#x27;d forego some techniques to prevent cross-site request forgery attacks. So unless you only want your web app do to read-only access to data, you need to implement some server-side code as well.
kypro12 个月前
Please don&#x27;t use React unless the websites you&#x27;re building would benefit from a reactive JS framework. You&#x27;re going to have to maintain dependencies, likely ruin your site&#x27;s accessibility and end up writing code far more complicated than is needed given your requirements.<p>The reason you feel out of touch is probably because most people who learnt webdev over the last decade basically grew up on React and are now building everything with React without any thought. Unlike TypeScript which was widely adopted by web developers because it&#x27;s superior to JS, React offers most projects nothing of value and is neither superior or a direct replacement for libraries like jQuery.<p>If you&#x27;re building simple websites then you don&#x27;t need a complicated stack. In fact, I&#x27;d even question why you feel the need to use jQuery in 2024... Keeping your stack as simple as possible is a good rule of thumb if you want to build things that require little maintenance and will be around for years to come.<p>If you&#x27;re struggling to build the interactivity you need with jQuery, then perhaps look at React. But even then I&#x27;m not particularly keen on React as a first option myself. If you&#x27;re a good JS dev and have good patterns in place you can build some very complicated stuff with Vanilla JS...<p>I&#x27;d also consider other frameworks. I&#x27;ve been doing web dev for about 20 years now and in recent years I&#x27;ve used React a lot, but I hate it. I find it&#x27;s very easy to write ugly and poorly structured React code. Next.js tries to add some structure, but urgh, I find Next.js far too complex for most use cases and in many cases creates more problems then it solves. In my experience React projects need to have a great team of developers behind them to not end up a total mess within a couple of years.<p>I think Svelte and Alpine.js are generally better options for most smaller projects which require some reactivity. That&#x27;s personally where I would look first.<p>The main reason I think you should move away from jQuery is simply that it&#x27;s not useful anymore. Back when vanilla JS had limited functionality and poor cross browser support jQuery was amazing, but today it serves no real purpose.
romanhn12 个月前
You can absolutely host the entirety of your React code on a CDN - in fact, that&#x27;s the preferred way of doing it. Node is used locally to generate the static resources needed by your app. There is also the server-side rendering approach enabled by frameworks such as Next.js - those indeed run on the server and provide a way of merging frontend and backend development.<p>To be honest, if jQuery has worked for you so far, it&#x27;s not clear to me you need to be switching. It&#x27;s possible your requirements just don&#x27;t have enough frontend complexity to make the change worthwhile. I&#x27;d suggest working through the excellent React docs and building something very simple. If it clicks - great! If not, you haven&#x27;t committed yourself to support tech you don&#x27;t need. Either way, greenfield is better, don&#x27;t jump into retrofitting an existing jQuery codebase.
pestatije12 个月前
jquery is a client lib, whereas react is a full stack where you can run server-side-rendering, access server services, and in general do everything server-side
评论 #40525357 未加载
solardev12 个月前
An opinion from someone&#x27;s who been doing web dev since the 90s (and who had to learn Perl and frames before jQuery + Bootstrap):<p>For me the big one is componentization. For example, take a look at <a href="https:&#x2F;&#x2F;mui.com&#x2F;material-ui&#x2F;all-components&#x2F;" rel="nofollow">https:&#x2F;&#x2F;mui.com&#x2F;material-ui&#x2F;all-components&#x2F;</a>. It&#x27;s kinda like Bootstrap in that it&#x27;s a bunch of UI widgets that you can easily compose into a site. But using React gives you an orderly way of maintaining and sharing state across these components, turning an API response (or several) into a tree of states that can be easily used, modified, and shared across components and pages. The jQuery way of doing that (in the old days, at least) would typically be global vars or else each widget handling its own fetches and data. But it&#x27;s not easy to pass that kinda stuff between widgets. In React + TypeScript it becomes very simple, once you learn it, to make such a dashboard with loading states, notifications, graphs, popups, etc. all synced to each other.<p>But, that said, not every site needs that kind of complexity. (And especially not every site needs Next.js on top of React). If you&#x27;re doing a simple blog, React is frankly overkill and will add unnecessary complexity. These days, you probably don&#x27;t need jQuery either. Modern ECMAScript is pretty good.<p>The dislike of React, IMO, is partially because it&#x27;s designed to solve medium-biz-to-enterprise-scale web problems where several devs have to work together on a codebase of sufficient complexity. It is hard to do that with the code soup of jQuery + Bootstrap because every component (or at least every page) tended to have its own way of doing things. React, especially with a modern framework, tends to enforce a top-down way of fetching state and storing it in some store and then propagating that down to pages and components, which means that each page becomes like a function... you can properly separate its inputs from its outputs. That means one dev can be responsible for the inputs (like an API response, or a structured state derived from the response) while another dev can focus on making&#x2F;modifying the UI around that response, all without touching other parts of the codebase.<p>That initial problem, once solved, then created a HUGE explosion of secondary things, like serverside rendering&#x2F;static building (for performance reasons), package management (NPM, yarn, etc.) for tracking &amp; locking third-party package versions, various state management libs (for really complicated frontends... most don&#x27;t need anything like that), routers (because React was born in the clientside single-page-app infancy, alongside Angular and other hash-based clientside routers)... but all of those things aren&#x27;t really &quot;React&quot;, just things that people added TO React in order to make it more batteries-included (because they wanted to keep using React, but React didn&#x27;t have those things out of the box). That&#x27;s a different, after-the-fact approach vs something like Angular which tried to include those bolts from the get-go (and had an even higher learning curve, and died shortly thereafter).<p>Next.js in particular is the combination of many of those concerns, rolling up package management, typescript, serverside rendering, etc. into one &quot;convention, not configuration&quot; setup that you can deploy with a single `create next app` command and deploy onto Vercel in 2 minutes. It&#x27;s an incredible framework for those who need its power, but it&#x27;s also a lot of complexity for those who don&#x27;t.<p>Honestly, if jQuery is working fine for you (and your clients don&#x27;t need anything more complex), all I&#x27;d consider doing is seeing if you can replace jQuery with modern ECMAScript selectors&#x2F;methods. But there&#x27;s no reason to jump ship to React unless you have a professional need for it.<p>If you do (like your frontends are getting more complex), I&#x27;d also investigate other frameworks&#x2F;libs too, like Svelte, Vue, maybe HTMX, etc. and see which one fits your needs the best. The only significant advantage that React has over those is hireability&#x2F;popularity. It&#x27;s become the de facto business-scale frontend (way more than the others), even though it&#x27;s not the easiest to learn or use.