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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

An SPA Alternative

278 点作者 vimota将近 3 年前

21 条评论

noidexe将近 3 年前
For me this feels like finally jumping back to the good timeline.<p>From the user point of view, I think there are two main types of experiences on the Web:<p>a ) Interactive documents. Basically web 1.0 but today we want fancier transitions and interactions. This can be provided by htmx and should always have been developed declaratively. It should ideally be provided by the browser and htmx shouldn&#x27;t need to exist. Examples of this are Gmail and most social networks and forums including this one.<p>b) Desktop apps-but-I-don&#x27;t-want-to-have-to-install-them. This would be things like Google Docs, Photopea and most real-time games. To deliver this, right now we have a browser that has become almost an OS inside an OS, to the point only Google can keep up with the complexity. On top of that, we pretend apps are documents and for all the imperative code we need we use a scripting language that was not meant for that, and we need a really complex VM just to keep it more or less performant. For this use case I think at some point we should move all the way into just delivering apps, if not native apps, something like wasm, where the browser tab would just be a vm player.
评论 #32159771 未加载
评论 #32159872 未加载
silviogutierrez将近 3 年前
I&#x27;m the creator of Reactivated[1] and fully agree with a lot of the aversion to SPAs [2] and REST [3][4]<p>But to me, writing my markup in JSX (really, TSX with TypeScript) and using scoped CSS solutions was too good to pass up. I just couldn&#x27;t bear writing text-based templates.<p>That&#x27;s why I built Reactivated: combining the best of both worlds. Server-rendered, simple markup — albeit still in TypeScript — but you can add interactivity as needed.<p>Of course, HTMX is far less opinionated and framework-agnostic. So it can be used with any number of libraries &#x2F; stacks.<p>[1] <a href="https:&#x2F;&#x2F;www.reactivated.io" rel="nofollow">https:&#x2F;&#x2F;www.reactivated.io</a><p>[2] <a href="https:&#x2F;&#x2F;www.reactivated.io&#x2F;documentation&#x2F;philosophy-goals&#x2F;#traditional-serverrendered-views-work-well" rel="nofollow">https:&#x2F;&#x2F;www.reactivated.io&#x2F;documentation&#x2F;philosophy-goals&#x2F;#t...</a><p>[3] <a href="https:&#x2F;&#x2F;www.reactivated.io&#x2F;documentation&#x2F;philosophy-goals&#x2F;#rest-is-not-the-way-not-always-practically-never" rel="nofollow">https:&#x2F;&#x2F;www.reactivated.io&#x2F;documentation&#x2F;philosophy-goals&#x2F;#r...</a><p>[4] <a href="https:&#x2F;&#x2F;htmx.org&#x2F;essays&#x2F;how-did-rest-come-to-mean-the-opposite-of-rest&#x2F;" rel="nofollow">https:&#x2F;&#x2F;htmx.org&#x2F;essays&#x2F;how-did-rest-come-to-mean-the-opposi...</a>
recursivedoubts将近 3 年前
I am the author of this article. Happy to answer questions.<p>I know my alternative approach, htmx-enhanced hypermedia, isn&#x27;t right for every application, but it can be a much simpler approach for many applications, and, since it is so simple, can be used to conserve complexity in applications that have parts that are not amenable to the hypermedia approach.
评论 #32158352 未加载
评论 #32159902 未加载
评论 #32158876 未加载
评论 #32158810 未加载
评论 #32158255 未加载
vladstudio将近 3 年前
Every time I see an essay from Carson, author of HTMX, I upvote instantly!<p>Make sure to check other essays at <a href="https:&#x2F;&#x2F;htmx.org&#x2F;talk&#x2F;" rel="nofollow">https:&#x2F;&#x2F;htmx.org&#x2F;talk&#x2F;</a> (scroll down for Essays)
jasongi将近 3 年前
I have noticed that there is a dogmatic element to a lot proponents of these libraries which leaves a sour taste in my mouth.<p>Occasionally you get a head nod in the direction that “sometimes, React is the best tool” but most of the time it’s Simpsons memes stoking a culture war.<p>If you’ve worked in an org where someone with decision making power has drunk the “progressive enhancement not SPA” koolaid, then it’s just as bad as someone who has drunken the SPA always koolaid - at least you’ll find it easy to hire and find support&#x2F;libraries with the latter.
评论 #32160366 未加载
rlawson将近 3 年前
I have used htmx (and it&#x27;s predecessor intercooler) on several occasions now.<p>The real sweet spot is it allows you to push server side frameworks like Django even further. You may find you can skip the SPA all together. And nothing beats the speed of development of a Django&#x2F;Rails&#x2F;Laravel.<p>Htmx is part of my go to stack for solo&#x2F;side projects and my preferred stack on the job for crud heavy line of business applications.
评论 #32207933 未加载
drchaim将近 3 年前
I&#x27;ve been trying htmx and the results are great. So much simpler to code than with SPA. My only concern is about those datetime pickers and other type of &quot;components&quot; that is easy to get from a react&#x2F;vue ecosystem but much harder in a vanilla Javascript way. Not saying it&#x27;s impossible, but a bit harder to find decent maintain libraries&#x2F;components for those kind of web interactions.
评论 #32159655 未加载
评论 #32159039 未加载
评论 #32157595 未加载
评论 #32159189 未加载
评论 #32158060 未加载
quickthrower2将近 3 年前
Has anyone got battle stories from using HTMX it similar? I there a time you regretted it a little and wished you had chosen React? Or is it pretty rosy?
评论 #32159460 未加载
评论 #32163383 未加载
kulor将近 3 年前
I’ve found this library a delight. Coupled with a sprinkling of Alpinejs to cover more advanced interactions and Django-livereload, I feel progressive enhancement has a renascence opportunity
daotoad将近 3 年前
I&#x27;m pretty sure I&#x27;ve said this on previous mentions of htmx, but I&#x27;ll say it again: this reminds me of the old SPF framework youtube published.<p><a href="http:&#x2F;&#x2F;youtube.github.io&#x2F;spfjs&#x2F;" rel="nofollow">http:&#x2F;&#x2F;youtube.github.io&#x2F;spfjs&#x2F;</a><p>SPF was a bit more focused on being easy to merge into an existing server side app.<p>I am glad to see this and hope it has some legs. It could help free us from the need to write every UI in JavaScript(ish).
评论 #32159452 未加载
no_wizard将近 3 年前
this of course, is really meant for brochure or light interactivity sites. I don&#x27;t think Figma should convert to htmx. I also don&#x27;t think its meant for sites that may need to honestly scale as part of their product line heavy JavaScript interactivity. For instance, I&#x27;ve definitely worked at a place that deployed well over 10K components to production (I think we pushed over a million lines of deployed production code).<p>React &amp; Angular do scale this far, I have yet to encounter any who works with Vue that ships over a million lines of deployed code though I&#x27;d love to hear from you!
评论 #32158148 未加载
评论 #32158759 未加载
评论 #32158026 未加载
MrWiffles将近 3 年前
What&#x27;s the actual advantage of HTMX over something like React or Vue? All 3 require some form of JavaScript library coupled with markup to build interfaces. While I&#x27;m all about killing JavaScript as much as possible (why should I let $MEGACORP execute code on my device all willy-nilly without any real restrictions?), I just don&#x27;t see the tangible benefit to the end user here.<p>(And don&#x27;t start with &quot;it&#x27;s faster&#x2F;more efficient&quot;, that comparison isn&#x27;t terribly valid because the inefficiencies seen with React&#x2F;Vue are largely an artifact of bad code&#x2F;practices, not the libraries themselves.)
评论 #32155082 未加载
评论 #32159238 未加载
评论 #32157833 未加载
评论 #32158568 未加载
评论 #32158016 未加载
评论 #32159188 未加载
评论 #32154325 未加载
评论 #32155173 未加载
tr1ll10nb1ll将近 3 年前
One of my apps built on the Django+HTMX stack got traction and no matter how much I loved using HTMX, I found it’s not feasible to keep a clean codebase (facilitating new developers on the team as well) with this stack.<p>[Tetra](<a href="https:&#x2F;&#x2F;www.tetraframework.com&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.tetraframework.com&#x2F;</a>) might be an alternative if you’re hell-bent on not using React.<p>But, if you want to ship quick, have a maintainable codebase in a technology a lot of devs are familiar with and have the power to instantly ship for mobile (and buy yourself some time to build one in React Native; code is going to be <i>similar</i> to React.js), I’d recommend using React.<p>You can use Capacitor.js for instantly shipping a mobile app with your codebase that “just works”. Use Capgo for affordable codepush and you’re set!<p>HTMX all the way if you’re not building an app cause not everything is an “app”.<p>At the same time, if you’re building an app with a framework unlike Phoenix, I don’t see why one would not go ahead and use a decent JS framework. Using frontend framework seems to be facing a lot of aversion and I don’t understand if it’s because of the inability to learn these frameworks or what.<p>Point is, your users just need a snappy app that works. That’s it! And using a robust frontend framework makes it easier.
jmull将近 3 年前
Here&#x27;s the &quot;motivation&quot; for htmx, from it&#x27;s main page:<p><pre><code> Why should only &lt;a&gt; and &lt;form&gt; be able to make HTTP requests? Why should only click &amp; submit events trigger them? Why should only GET &amp; POST methods be available? Why should you only be able to replace the entire screen? By removing these arbitrary constraints, htmx completes HTML as a hypertext </code></pre> I think the first three items are minor issues, at best, which in no way justify yet another DSL.<p>The fourth is a reasonable point -- it&#x27;s quite common that you only want to update a portion of a page.<p>But it&#x27;s very unclear that HTTP requests are the way to do it.<p>For one thing, using HTTP requests as the transport for app event handling adds nothing conceptually. It seems nice to use something that people are widely familiar with to build an event model on top of, but HTTP isn&#x27;t a good fit for everything. So you either need something else (javascript or another language&#x2F;api&#x2F;framework) or you awkwardly fit everything into this model anyway.<p>But more importantly, it implies a strongly hierarchical structure to your app UI, which I think is overly rigid and unrealistic. Content tends to be largely hierarchical, but frequently important cross-cutting concerns pop up... maybe not on day one, but maybe on day 100 or 1000. Now you&#x27;re swimming upstream.<p>Also, it&#x27;s not like there aren&#x27;t a very high number of HTML-centric options available. It has an interesting low-level approach, but in the end we&#x27;re developing apps and UIs. It&#x27;s very unclear to me whether htmx really offers advantages that other approaches don&#x27;t meet or exceed.
评论 #32160690 未加载
jdthedisciple将近 3 年前
Naive question but how would styling be handled actually? If the server just returns plain html tags with content in it ... I mean, I don&#x27;t quite get it
评论 #32158212 未加载
评论 #32158155 未加载
评论 #32158146 未加载
danbulant将近 3 年前
Kind of reminds me of sveltekit. For example, I hate writing the same HTML repeatedly, so I just used svelte for it&#x27;s components and made a fully static, JS-less page. That later evolved and left out the JS-less (some fancy effects, dialogs, cross-page transitions etc), but even for building static pages seems far better than writing normal HTML, when those pages become a bit complex.
soruly将近 3 年前
I think Turbolinks is a nice balace bewteen traditional webpage and SPA. <a href="https:&#x2F;&#x2F;github.com&#x2F;turbolinks&#x2F;turbolinks" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;turbolinks&#x2F;turbolinks</a><p>It provides a smooth UX by fetching next page&#x27;s HTML in background, then replace the DOM by compareing the diff in HTML. So you won&#x27;t see a blank page while navigating between pages.
评论 #32163180 未加载
评论 #32162590 未加载
NorwegianDude将近 3 年前
I have been doing something similar where a js file takes over links and forms and uses fetch to get content and some other data on navigation.<p>Great TTFB as I don&#x27;t need to send it to node to render js, faster navigation for many users with slow plugins and easy to implement.<p>This seems to do the same thing, and much more. I really need to try htmx, looks cool!
calderwoodra将近 3 年前
What are the pain points developers have with SPAs? I&#x27;ve been working on a nextjs&#x2F;react&#x2F;tailwindcss project for 5 months full-time now and I honestly love it. It&#x27;s been very intuitive and straightforward to get things done.
评论 #32166165 未加载
hencq将近 3 年前
I really love the idea of htmx and will definitely use it for my next hobby project. Out of curiosity, does htmx only work for always online apps or could you build a PWA with offline capability with it as well?
评论 #32172400 未加载
zagrebian将近 3 年前
When was this published?