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.

You probably don't need a single-page app

816 pointsby ukutahtover 6 years ago

80 comments

save_ferrisover 6 years ago
This. So much this.<p>My company (4,500+ people) ordered all products in their portfolio (~12 web apps) to migrate to SPA front ends about a year ago as a way to stand out from our competitors, and boy has it been painful.<p>Prior to that initiative, we had been using the hybrid approach mentioned in this piece, embedding SPAs only where necessary and sticking to SSR everywhere else, which worked really well.<p>Since the announcement, our productivity has diminished dramatically since so much of our time is now focused on re-working functionality that already exists into an SPA, and it&#x27;s completely unnecessary. Not only that, but extending these UIs will take more time in the future than their SSR versions due to the added complexity of the front end frameworks, and we&#x27;re definitely going to make mistakes along the way that we weren&#x27;t making before.<p>It drives me crazy to think that some exec came up with SPA-ing everything as a sales pitch to clients, when 99.9% of our clients have no idea what an SPA is. And the amount of money being spent on turning already-working apps into SPAs is astronomical.
评论 #19185871 未加载
评论 #19185764 未加载
评论 #19185218 未加载
评论 #19186741 未加载
评论 #19188122 未加载
评论 #19186417 未加载
评论 #19186172 未加载
评论 #19185723 未加载
评论 #19185597 未加载
评论 #19188324 未加载
评论 #19185973 未加载
评论 #19188021 未加载
评论 #19188846 未加载
评论 #19185898 未加载
评论 #19187161 未加载
评论 #19189558 未加载
评论 #19185503 未加载
评论 #19186362 未加载
评论 #19185651 未加载
评论 #19197288 未加载
kyledrakeover 6 years ago
Agree with the article. I find server views to be substantially easier to work with.<p>But more importantly, I also find server view rendering to be a faster, better UI experience. It&#x27;s really frustrating having to wait several seconds for a SPA to load, or to have unexpected behavior when clicking the browser back button, or failing completely because some random hunk of JS garbage errored out, and it&#x27;s one of the big contributors to why I don&#x27;t really like using Facebook or Twitter anymore. They murder my browser with megabytes worth of slow SPA crap to give me less than a few kilobytes of meaningful data (and&#x2F;or people screaming at each other). Gmail now takes 10-20 seconds for me to load at this point, on my high end laptop. I just want to switch to HTML mode by default.<p>I definitely get edge cases like Slack, but honestly don&#x27;t think SPA has been a positive development, overall. I think the web was better as a document&#x2F;HTML oriented design.
评论 #19184938 未加载
评论 #19186363 未加载
评论 #19186750 未加载
评论 #19185062 未加载
评论 #19184916 未加载
评论 #19185419 未加载
评论 #19185902 未加载
评论 #19187695 未加载
评论 #19188716 未加载
评论 #19187803 未加载
评论 #19186616 未加载
cfvover 6 years ago
You probably don&#x27;t <i>need</i> a single-page app, right up to the point where it&#x27;s a business requirement and you have to translate a GB worth of convoluted JSPs into one because the client likes smoothness in their flows, continuous saving, and all those nicely choreographed state transitions you just cannot get without having a framework hijack the History and File APIs from the browser&#x27;s paws.<p>Yes, a nice state machine-like flow with each thing happening only once at a given time is great, right until you get asked to make it so that clicking on a thing shouldn&#x27;t reset all user input, and progress of a task should be communicated live, maybe while we also we want this app to just not show a blank screen like, ever, just comes and happens to you and that&#x27;s what you kind of have to do now.
评论 #19185650 未加载
评论 #19185201 未加载
评论 #19185580 未加载
评论 #19185712 未加载
lmilcinover 6 years ago
All that complaining serves no purpose. SPA is just another tool in a belt. Where I think it shines is making rich apps that need complex flow and communication. This is where productivity is important and the process is complex and up until recently I would be advocating native desktop app. Now with advent frameworks that help me organize this very efficiently (I use re-frame&#x2F;reagent with ClojureScript) I can create complex SPAs without the project collapsing under its own weight at some point.<p>I don&#x27;t want to say you should use SPA frameworks for anything, don&#x27;t make your company website with SPA. What I want to say that if you have a complex process you can consider creating &quot;enterprise&quot; UI instead of trying to dumb it down to a series of billion simple forms.<p>If you feel your business is overusing SPAs (is it so strange they want new shiny toy?) then as the technical person you need to educate them on pros&#x2F;cons of the technology.
评论 #19187834 未加载
评论 #19186901 未加载
评论 #19188733 未加载
paultopiaover 6 years ago
Unpopular opinion: I love SPAs for simple stuff. Yes, they&#x27;re a ton of work. But the feel of them is unparalleled.<p>I have my personal home page written as a Vue SPA. It was a silly amount of work to get together, and not everything works perfectly. BUT: it moves like a rocket. I pre-render the simple front page, so initial load is nearly instantaneous (especially with cloudflare &amp;c), and, by the time a visitor finishes absorbing the information on the front page (which is just a palmos style collection of icons to other content), everything else is loaded. Which means that the effective load time of the whole website is perceptually indistinguishable from zero on a moderate-speed connection (like my crappy home DSL).<p>And that&#x27;s... cool. It&#x27;s legitimately cool. Let me have my fun!
评论 #19188917 未加载
评论 #19187512 未加载
评论 #19188340 未加载
评论 #19187606 未加载
评论 #19187920 未加载
评论 #19189519 未加载
tyingqover 6 years ago
I&#x27;m more interested in the future of <i>&quot;you probably don&#x27;t need a native app&quot;</i>.<p>It feels like browsers are closing the gap pretty well with things like IndexedDB, offline features, WASM, etc. Still a ways off, but seems like it&#x27;s getting there.<p>I do worry, though, that it&#x27;s not really in Apple&#x27;s or Google&#x27;s best interest to move that along.
评论 #19184781 未加载
评论 #19186503 未加载
评论 #19184865 未加载
评论 #19184723 未加载
评论 #19184739 未加载
评论 #19185171 未加载
评论 #19184879 未加载
anonyfoxover 6 years ago
Having developed with nodejs since v0.4, went through jquery =&gt; backbone =&gt; angular (1) =&gt; ember =&gt; vue =&gt; react, written stuff in several incarnations of javascript (including coffee and typescript), used build tooling from grunt to webpack and customized browserify, even built stuff with meteor... i can‘t bear it any longer.<p>Actually now we are full circle again. Files that mix css&#x2F;template&#x2F;logic with FOTM syntax, add some database calls during SSR and you have basically PHP. Just more complicated tooling. Deploy your frontend on S3 and its similar to FTP to Apache Servers, except you can‘t update just individual files. Run your backend on AWS lambda and you have stateless backends like ... PHP, but with cloud vendor lock-in. State Management like „Flux“ that poorly resembles state machines on top of JS shortcomings.<p>I am personally switching completely to elixir&#x2F;phoenix to do anything web-related and can solve things cleanly within minutes. Also when Phoenix LiveView finally arrives, it could be groundbreaking and replace many usecases of modern SPAs.
BlackFlyover 6 years ago
I used to feel that way, then I met a one javascript developer in particular who really made me see it differently. I won&#x27;t get into those here, I just want to tone down the &quot;probably don&#x27;t need&quot; into a &quot;don&#x27;t necessarily need&quot;.<p>As a predominant back end developer, I do feel that the complaints from the article are due to inexperience or misunderstanding:<p>1. stateless requests: You don&#x27;t have to cache any state by default, just like server side. You start caching to improve performance and caching is always one of the big 2 problems of computer science. Don&#x27;t cache if you don&#x27;t have to: stateless has benefits.<p>2. Reinvent browser features: use your framework! This is a solved problem. I am not sure what the Angular or React solutions are but with vue just use the vue router.<p>3. More mature tools: backend suffers from this as well, I know a lot of mid level software engineers that are always chasing the latest fads. Microservices, containers, serverless, etc. The biggest issue I had when I tried to do serious frontend development is just not being aware of the tooling and how it works.<p>4. SEO: Google can crawl your webapp: <a href="https:&#x2F;&#x2F;searchengineland.com&#x2F;tested-googlebot-crawls-javascript-heres-learned-220157" rel="nofollow">https:&#x2F;&#x2F;searchengineland.com&#x2F;tested-googlebot-crawls-javascr...</a>, I would prefer if the person making the claim (that an SPA does not get crawled) would be the one providing the evidence...<p>Don&#x27;t get me wrong though. Sometimes an SPA is the wrong choice but it would be hard for me to say if that is usually, rarely or a toss up.<p>I think many places that go from server-side rendered to client-side rendered SPAs do not hire a bunch of front end experts when they do so. Then people experience a bunch of problems because of the fact I point out in 3: lack of awareness of the ecosystem. On the other hand, there sure are a lot of diva developers who don&#x27;t like working with old technology (for example, PHP), and this probably causes a lot of the front end framework churn. Just like picking up a new language, it takes time to produce idiomatic code. Of course, for a new framework it takes time for the idioms to develop...
评论 #19186588 未加载
评论 #19187045 未加载
评论 #19189076 未加载
danielovichdkover 6 years ago
I tried the other day, yet again, to give it a go. You know, firing up VS Code and make an app with express, node, react bla bla bla.<p>Coming from the .NET toolchain and expecting a lightweight, easy to start with approach I was yet again totally shocked.<p>The hundreds of possible directions you can go in, in terms of frameworks, packages and what not is ludacris.<p>I stopped working when my node modules directory topped 60mb and I still hadn&#x27;t made a data layer.<p>Good luck fixing that. I&#x27;d rather keep my code and tooling simple and clean.
评论 #19184891 未加载
评论 #19187279 未加载
评论 #19184875 未加载
评论 #19184936 未加载
评论 #19184859 未加载
评论 #19186316 未加载
评论 #19185091 未加载
评论 #19185081 未加载
评论 #19185054 未加载
评论 #19185856 未加载
评论 #19185719 未加载
ccalvertover 6 years ago
I have modest skills as a developer. I was trying to convert an old static web site into something more interactive. Without really thinking it through, I started building a SPA. I got stuck on the SEO part. I found it innately complex, but the real trouble came from trying to bring together the disparate sections of the old static site while preserving and abetting SEO.<p>One day I just ditched the SPA and rebuilt the whole architecture with NodeJs and Express. I was done in a few days. It could have gone even faster, but the original static site was really a mess with years of accumulated bad decisions embedded in it.<p>I know this is just one data point and not really proof of anything. Nevertheless, the linked article made a lot of sense to me. Most of the bulleted points resonated with me, but none more than the SEO issue. There are solutions to the SEO issue, but I personally did not find them easy to implement. If I were part of a big professional team, and we really needed a SPA, I would have called this one differently, but I was working on my own, and I didn&#x27;t really have the sense at first to see that I didn&#x27;t need a SPA to achieve my goals. I was perhaps a bit too susceptible to the hype without enough experience to really understand the issues involved.
评论 #19185270 未加载
评论 #19188916 未加载
dimglover 6 years ago
I can&#x27;t agree with this article at all. Having an JSON API and a small web app bundle that you can deliver with a highly-available CDN removes a ton of scaling problems related to SSR and gives a clean separation of concerns both from a managerial and architectural standpoint.<p>It also makes testing dead simple: you just make contracts on what the response bodies will look like and just feed mock data structures into your stateless web app. This allows the API team to make changes to the API layer with confidence that as long as they don&#x27;t change the contracts with the web app, everything will still work.
caseymarquisover 6 years ago
For new development, I reach for SPA tools (like VueJS with Webpack) fairly quickly. The reasons for this are:<p>1. Reusable web components. 2. Clear separation of backend and frontend logic. 3. Using the latest version of javascript.<p>I really like HTML&#x2F;CSS&#x2F;JS as tools for building GUIs, but I feel HTML&#x2F;CSS specifically suffer from the inability to make components.<p>I think there are definitely instances where there is no need for these tools. I would genuinely like to know how to manage the items listed above when this is the case. ie Recommended tools for when I go &quot;SPA seems like overkill for this... what are my other options for this functionality?&quot;
评论 #19184881 未加载
评论 #19184842 未加载
评论 #19187743 未加载
评论 #19187020 未加载
valerioboover 6 years ago
Totally agree with the article, the spa hype has produced a lot of crappy slow web sites and crippled productivity of many teams for years. I think ppl in the industry are way too young and have the bad attitude to nod add tools in their belt but keep only the last one that has hype. Spa are like applet or Silverlight, just different tech, same goes for ws* vs rest api and so on...
评论 #19185165 未加载
rorygibsonover 6 years ago
1) CRUD &#x2F; data entry systems: stay with request-response.<p>2) Complex webapps with snappy functionality that need to feel &quot;native&quot; - whatever that means: think about an SPA. Then realise that mostly what you need is (1).<p>3) Corporate homepages &#x2F; brochure sites &#x2F; product sites &#x2F; blogs: use a static site generator like Hugo, Jekyll etc. It&#x27;s amazing what you can do with a staticgen site now<p>[Insert shameless plug for Trolley, my product, <a href="https:&#x2F;&#x2F;trolley.link" rel="nofollow">https:&#x2F;&#x2F;trolley.link</a> ]
pcmaffeyover 6 years ago
The concept of a SPA is a total hack of web patterns. I predict in a few years we&#x27;ll refer back to SPA&#x27;s the way we do now to AJAX or DHTML.<p>We&#x27;re getting closer to the best of both worlds, where we SSR pages and then &quot;hydrate&quot; them with JS components. The tooling around this isn&#x27;t great yet, but it&#x27;s definitely all there.
amoitngaover 6 years ago
1. It&#x27;s like saying you don&#x27;t need Rails, just use Sinatra and if your app really needs it then use Rails. I&#x27;ll pick rails even for a super simple project because I&#x27;m very comfortable, quick with it.<p>2. &quot;You don&#x27;t need the complexity of SPA or javascript fatigue&quot; and then you install webpacker gem that wraps around webpack and not only you have a headache of webpack but also of a gem that wraps around it. And then you need some front end libraries and you start including them in in the way that feels like a workaround.<p>I mean no disrespect to these wonderful tools, I appreciate the hard work being put into these gems, and I will admit I didn&#x27;t give it TOO MUCH effort to learn. I tried it. didn&#x27;t feel right. moved on.<p>I&#x27;ve just decided for myself that for now I&#x27;m gonna keep my backend ( ruby, db, server ) in one mental bucket, and all the fronted ( css, js, html ) in another.<p>For me to go traditional Rails way it has to be a super simple app, at which point there will probably be other tools to solve the problem.
petilonover 6 years ago
I couldn&#x27;t disagree with this article more. Developing SPAs is easier than server-render applications. The problem is React, Redux, and other such libs make this more complicated than necessary. React is all about surgically making the smallest possible change in the DOM to refresh the page. But is that really needed? Most of the time it is not. Why not re-render the whole page? This is what happens in the case of server-render applications any way, right? Turns out 99% of the time it is performant for the SPA to rerender the whole page. Instead of Angular and React, if you use simple libraries such as UIBuilder ( <a href="https:&#x2F;&#x2F;github.com&#x2F;wisercoder&#x2F;uibuilder" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;wisercoder&#x2F;uibuilder</a> ) and MVC router ( <a href="https:&#x2F;&#x2F;github.com&#x2F;Rajeev-K&#x2F;mvc-router&#x2F;" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;Rajeev-K&#x2F;mvc-router&#x2F;</a> ) you can build simpler applications that work well and are super easy to develop and maintain. Each of those libs is less than 500 lines, so super easy to learn and use.<p>This article says traditional web servers are stateless, but in the case of SPAs servers are stateful. The opposite is true. Traditional web servers have session state, but in the case of SPAs the servers can be stateless because all servers are responsible for is persistence and query&#x2F;search.<p>This article says maintaining browser history is a mess in SPAs. Not true. The same MVC architecture that works so well on the server can be done just as easily on the client, see this lib: <a href="https:&#x2F;&#x2F;github.com&#x2F;Rajeev-K&#x2F;mvc-router&#x2F;" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;Rajeev-K&#x2F;mvc-router&#x2F;</a><p>This article says server-rendering has fewer more mature tools. That may be true. There are so many new tools for SPAs. But you can ignore them and build SPAs trivially using the libs mentioned above.<p>This article says server-rendering is better for SEO. Not true anymore. Google and Bing crawlers now execute javascript to crawl your content. This is more work for Google and Bing but not more work for you.<p>If you know how to do it SPAs are the easiest and best approach because all the server needs to do is implement persistence and query&#x2F;search using a REST API. If you later need a native mobile client this approach is already more compatible with mobile than if the server renders HTML in addition to persistence and query&#x2F;search.
评论 #19185099 未加载
评论 #19184871 未加载
pier25over 6 years ago
I&#x27;ve been making SPAs for a couple of years now and I totally agree.<p>Not only the complexity of development is increased, but there is no real benefit for the vast majority of use cases.<p>I think there is merit in using an API though and clearly separating data from presentation.<p>What I&#x27;ve been doing lately is using Jekyll with Vue components for some in house projects. It works great.<p>Another option I&#x27;ve been trying out is doing SSR in JavaScript on Zeit Now monorepos. Haven&#x27;t used it in a real project, but so far it&#x27;s awesome. You can keep using all your front end knowledge, but render each route on the server. No more managing state (Redux, Vuex, etc) or router.
nkozyraover 6 years ago
While I&#x27;ve long been more comfortable with server rendered pages, I feel like we&#x27;re oversaturated with this sentiment. I don&#x27;t think it matters all that much.<p>The message is build with what accomplishes your goals and works with your team&#x27;s skills.<p>The notion that SPAs are only good for certain types of applications or organizations doesn&#x27;t make much sense to me.<p>Building server-generated web sites works faster for me because I&#x27;m still more comfortable with it. SPAs make concessions but so do server generated apps.
评论 #19184679 未加载
bzalaskyover 6 years ago
The answer to whether a single-page app is appropriate for a given project needs to consider product requirements, team structure and available resources.<p>Libraries like React are awesome for breaking down complex (or even not so complex) UIs into story sized chunks that can be tackled by different engineers or even different teams. This is one of the biggest reasons to consider using them, IMO.<p>Even in the case of relatively unremarkable CRUD application, if the backend is split across multiple services and teams it may be entirely reasonable to choose to build a SPA frontend with a dedicated team.<p>On the other hand, if you&#x27;re building a Rails app with a small team, and most engineers are working full-stack out of necessity, a SPA may not be appropriate.<p>As companies grow, I&#x27;ve found roles tend to become more specialized. Your decision to build a Rails web app early on could be considered legacy cruft (by some) down the road because it can be difficult to break down and deliver a feature across the full stack if you&#x27;re not accustomed to building web apps that way.<p>There are tradeoffs to all of these approaches (including the hybrid approach). Ultimately, you need to do what&#x27;s what right for your product and team(s), and make your technology choices intentional.
评论 #19185058 未加载
评论 #19185001 未加载
alexandernstover 6 years ago
The main problem with SSR is that the moment you want to do something a little bit outside of the-happy-path of your framework o choice, you&#x27;re knee deep into sh<i></i>.<p>Let me give you the simplest possible example. A form with multi-dependant inputs: you select an option from a dropdown, and depending of the choice you made, you see another dropdown with some options, or maybe an entire new set of inputs. Maybe there is a button that will open a popup with another form, dynamically generated based on what you choose. Or maybe there is data you must dynamically fetch from the server, based on some combination of actions that the user did.<p>You can play the &quot;.show()&quot; and &quot;.hide()&quot; game with plain JS, but if you have more than 5 inputs, I promise you, you&#x27;ll be really sorry for choosing that method.<p>You can also &quot;inject&quot; somehow any SPA just into that particular view in your project, but then you&#x27;ll be already dealing with the cons of both SPA and SSR. It doesn&#x27;t pay off.<p>I have been doing all types of FE and BE development, and what has given me the best results is making the BE a REST API and doing the rendering on the frontend.<p>Just my 2 cents.
评论 #19184752 未加载
wrestlermanover 6 years ago
I have the same opinion. Building SPA is f* hard and time-consuming. But it depends. If you know how to build SPA fast, then, by all means, go that route. (As a solo dev or small team)<p>I use Rails, but Rails views are a disaster. You can use a lot of different patterns&#x2F;gems, but still, logic is highly coupled with the view layer. Personally, I like Phoenix approach with templates + views. But still writing script tags makes me cringe a little bit.<p>But I wouldn&#x27;t discourage people from using SPAs, though. If you are gonna have a lot of buttons, modals, different tables, charts, forms and stuff like that, I would go SPA. Or first serverside -&gt; SPA. Especially, when you are working in the team, it&#x27;s so much easier to tell one person to craft this json api and another to craft this design with a consumer for the json api.<p>That become long... in short: if you have a small team or solo go server side 99%. If you have a big team or app that&#x27;s gonna be very heavy UI -&gt; go full spa or go server(mvp) -&gt; spa
评论 #19185075 未加载
ozimover 6 years ago
I don&#x27;t get &#x27;SEO for free&#x27; argument. You don&#x27;t SEO application, you SEO landing page and you don&#x27;t want crawlers to crawl your app.
评论 #19185924 未加载
评论 #19189083 未加载
评论 #19185121 未加载
syllable_studioover 6 years ago
I have experience building both SPA apps and server-side templated apps. They each have their strengths and weaknesses.<p>Just as a SPA won&#x27;t solve all your problems without any trade-offs, getting rid of a SPA framework also won&#x27;t solve all your problems -- you&#x27;ll probably need to re-invent some wheels and then discover that your new solutions are hard too.<p>I think it&#x27;s good to have a healthy dose of skepticism about new technologies. But it&#x27;s also important to understand their value and not to hate them just because they&#x27;re hard. I like that the author tries to find this ballance. Though, honestly, from my own experience, I would rename this title to &quot;You might not need a single-page app.&quot;<p>More than once, I&#x27;ve tried to build something without a SPA framework only to realize that if there is any interactivity at all, it&#x27;s often just simpler to use a SPA framework in the first place.
评论 #19185663 未加载
rajangdavisover 6 years ago
I used to love SPA&#x27;s but, in my experience, the most poorly organized SPA code is severely more complex than poorly organized server side rendered app code.<p>With SPA&#x27;s, you&#x27;re usually dealing with some build system, a variety of dependencies, and a swathe of design patterns. At worst, you have everything located in a single file which has all of the above across tens of thousands of lines.<p>With server side rendered code, you are (at worst) following someone&#x27;s code that didn&#x27;t follow the correct separation of concerns. At worst, the spaghetti code will be within a couple thousands of lines of code.<p>I had a project recently where I ran into both of the above scenarios and I would prefer to debug poorly written server-side code than poorly written SPA code. It&#x27;s night and day in terms of complexity.
skinnyarmsover 6 years ago
How about build-time rendering?<p>Server-Side rendering tightly couples your front-end to your application server. Scaling the site means scaling up that application server. A bug in one &quot;page&quot; of the app can cause the whole application server to go down.<p>If you leverage client-side rendering then it&#x27;s easier to decouple your front-end from the back meaning you can take advantages of things like segregated micro&#x2F;serverless services and progressive web apps. You can also re-use those services for multiple applications, making it easier to keep the business logic OUT of your pages and in an API layer where they belong.<p>I agree that SPAs are not the solution for everything, but I think that server-side rendering is on it&#x27;s way out.
评论 #19185291 未加载
评论 #19187201 未加载
评论 #19185404 未加载
joduplessisover 6 years ago
The massive problem with this approach is that more and more the requirements we see are exactly where SPA&#x27;s shine: real-time elements, rich UI and eventually PWA implementation when&#x2F;if. I agree that the traditional SSR has served everyone well - but I don&#x27;t think we need to be stubborn about what has worked vs. what can work.
评论 #19185398 未加载
potenchover 6 years ago
“do I need a component library?” is the question I ask when deciding to use react or not.<p>It’s a totally different question to ask do I need a spa or a server rendered app, both can be dead simple or heinously complex or reasoned away to prove a point...<p>I 100% of the time want (1) to architect my UI as a collection of atomic, reusable components, (2) get page specific server rendered html per route, and (3) do JS in a sane way (manipulate DOM, manage client state, and support a series of interactions that do not reload the page.)<p>So, what are my options?<p>1. React&#x2F;node 2. Sacrifice one of the above.
评论 #19185402 未加载
评论 #19187102 未加载
sametmaxover 6 years ago
Or microservices.<p>Or nosql.<p>Or containers.<p>Or graphql.<p>Free tech is not zero cost tech. Size your stacks to your actual needs.
评论 #19184914 未加载
ldiracdeltaover 6 years ago
One of the biggest reasons I reach straight for React is that I then have only one UI language. Instead of templating on the server in python or c# and then doing any UI updates in javascript on the client, I only have to write templating code in React and it runs on client and server.
评论 #19185583 未加载
dsegoover 6 years ago
One problem we&#x27;re having with the hybrid approach (Laravel + Mithril) is not being able to reuse common UI components between php &amp; js rendered parts. Laravel has blade templates, and mithril is coded similarly to react.<p>The other problem is deciding which to use when starting a new feature or section. A page may start out fairly static but end up needing a rewrite when the specs change and start requiring more dynamic UI elements.
评论 #19185785 未加载
评论 #19184866 未加载
Trisellover 6 years ago
It seems like a good 80-90% of the hate of SPAs doesn’t seem to be aimed at SPAs as much a poor programming and poor user experience because of that. In a lot of the cases that people here use. It’s not the SPAs fault as much as the programmers that messed it up. And honestly why do we think that putting it all back to SSR is magically going to fix poor programming?
评论 #19187403 未加载
noir_lordover 6 years ago
&gt; Frameworks like Rails, Phoenix, Lavarel, etc. have been around for a while and they are very stable.<p>Laravel is stable in production but they break backwards compatability all the time and not always in major versions.<p>Symfony is <i>much</i> better about it.
subpixelover 6 years ago
On the one hand, site like <a href="https:&#x2F;&#x2F;dev.to&#x2F;" rel="nofollow">https:&#x2F;&#x2F;dev.to&#x2F;</a> that are built in Rails and rival the speed and performance of any _static site_ support the argument that you can just use the tools you know.<p>On the other hand, to get your Rails site to function that well takes a lot of work - it is by no means the starting point.<p>Systems like Next.js and Gatsby.js and others are attractive in that A) they offer the ability to use both server-rendered and client-rendered React, and B) exceptional performance is the starting point. It&#x27;s up to you to slow it down, not speed it up.
评论 #19184923 未加载
fmaover 6 years ago
So, a question coming from a guy who&#x27;s been doing Java backend processing for a long time and thinking of making a side project. Was going to go the Angular route, but I&#x27;d like to have good SEO. I&#x27;d also like to get a POC&#x2F;MVP up and running to build momentum...don&#x27;t want to waste time on the front end when it&#x27;s basic form submissions to kick off data processing.<p>To show how long it&#x27;s been since I&#x27;ve done front end...My last &#x27;full stack&#x27; development had plenty of tables to style the application <i>grin</i>.
评论 #19186472 未加载
评论 #19185373 未加载
buu700over 6 years ago
Anecdotal: cyph.com started off as an SPA, mainly so we could share some components and styling with our actual application — and ever since we migrated to a static WordPress site with a handful of Angular Elements it&#x27;s been both a lot easier to maintain and way faster for end users.<p>(Sure, we could&#x27;ve gotten similar performance with server-side rendering, but at least with the current state of SSR tooling that would&#x27;ve been way more distraction from building our product than we could justify.)
asaddhamaniover 6 years ago
I agree with this so much. These days, the first thing developers will do when making a new app is setup babel + webpack + react + redux, then make an API, all for mostly CRUD applications.<p>Most applications don&#x27;t require these frontend frameworks, and it just adds needless complexity in most cases. I&#x27;ve suffered due to this, and so I&#x27;ve recently made the move back to server rendered apps.<p>And Rails with Turbolinks + UJS might not perfect, but it gets you like 80% of the way there for 10% of the effort.
oblibover 6 years ago
This article feels to me like complaining about making the simple difficult.<p>Since I work alone I suppose I&#x27;m not up to speed on what defines a single page app but the apps I&#x27;ve been building with PouchDB, jQuery, and Bootstrap run in a single page.<p>&quot;Stateless requests Traditional web servers are built to be stateless. &quot;<p>True, but &quot;apps&quot; should be designed to be self-contained (i.e. all the user navigation is done within the app UI, not the browser UI).<p>&quot;The browser knows how to deal with a traditional architecture If you go with the SPA route, you’ll always need extra code to emulate trivial browser features.&quot;<p>That&#x27;s a pretty trivial problem and browsers don&#x27;t really solve that, nor should they.<p>&quot;Fewer, more mature tools Avoid the Javascript fatigue by not relying so much on Javascript!&quot;<p>The apps I&#x27;m building are almost entirely Javascript. I see that as a good thing. What little I do on the server side I do with Perl, which is something I&#x27;ve been doing since the `90s, so I can feel &quot;traditional&quot; doing that if it helps me sleep at night.<p>&quot;SEO for free Single-page apps have to add extra infrastructure and code to make sure they can be indexed by crawlers.&quot;<p>This is not so difficult to address and in some cases it&#x27;s not even a consideration. In the case of a &quot;blog&quot; app you can simply assign a url to a post and deliver a page built on the fly specifically for it. Google can parse that.
评论 #19185795 未加载
1steover 6 years ago
Not very convincing.<p>React was introduced in 2013 and angular 2 was created in 2015.<p>The only server side rendering I&#x27;ll be doing in the future is with the likes of nextjs or similar.
评论 #19186277 未加载
nojvekover 6 years ago
I’m an advocate for SPA’s when they make sense. They have a clear niche. When you need to build an “application”. Like photoshop. Not a simple website that serves information.<p>Most websites are best served by serverside rendering. Or some form of hybrid where you only send the templates as JS that will be in need.<p>With SPA’s what usually ends up happening is that the whole app is sent in the first load. All the views, their css and shebang. &lt;1% is actually used by the browser. This is where most hate comes from. Most people give a shit about “time to first meaningful paint”. It’s what makes up for that “wow that was fast experience”<p>You can optimize both SPAs and server rendered pages for ttfcp. The former requires a lot more discipline.<p>Browsers also do a lot to render as quickly as possible without the whole page being downloaded. With html it’s simple and they have a lot of streaming tricks.<p>JavaScript is not that simple. It blocks the eventloop and the payload is downloaded in full, executed and then a paint can happen.<p>There are trade offs. SPAs can offer high interactive experience when server side rendering cannot.<p>SPAs are great. Just don’t throw everything away. We need the baby.
clessgover 6 years ago
Personally, I&#x27;m very interested in the possibility of Phoenix LiveView giving us the best of both worlds: <a href="https:&#x2F;&#x2F;dockyard.com&#x2F;blog&#x2F;2018&#x2F;12&#x2F;12&#x2F;phoenix-liveview-interactive-real-time-apps-no-need-to-write-javascript" rel="nofollow">https:&#x2F;&#x2F;dockyard.com&#x2F;blog&#x2F;2018&#x2F;12&#x2F;12&#x2F;phoenix-liveview-intera...</a>
评论 #19187172 未加载
manigandhamover 6 years ago
Agree that SPAs are usually unnecessary. The big problems with JS SPA&#x27;s is due to the limitations of javascript and the browser runtime. The one major innovation has been component-based view models while server-side frameworks have been stuck with older template-based approaches.<p>Component-based views are starting to get to server-side frameworks so that should reach parity within 2 years and WebAssembly will change the rest. Now apps can be built using many different languages with OOP&#x2F;functional styles, strong typing, dependency injection, etc, and run at native speeds in the browser. With the next gen of WASM running threads, GC, and DOM abilities, JS frameworks will likely start a slow death as the existing web frameworks start to have both server and client side delivery models.<p>ASP.NET Core with Razor&#x2F;Blazor is a great early example of this: <a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=Qe8UW5543-s" rel="nofollow">https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=Qe8UW5543-s</a>
EGregover 6 years ago
Serious question:<p>At <a href="https:&#x2F;&#x2F;qbix.com&#x2F;platform" rel="nofollow">https:&#x2F;&#x2F;qbix.com&#x2F;platform</a> we wanted to stick closely to the Web standards so we built a hybrid - although new pages would be loaded with AJAX, out of the box we made the “easy development path” cause every to page load from the server. This was because back when we started, search engines and other crawlers didn’t execute Javascript very well.<p>We always kinda felt bad that we didn’t “fully” embrase the “new and best” SPA trend, but also felt good we were giving people choice and were more compatible with Web Standards. And now as time goes by I see more and more of our choices vindicated. Is this anti-SPA backlash just another fad? Or were we right to give people two ways to render the same page - one on dynamic navigation and one on refresh?<p><a href="https:&#x2F;&#x2F;qbix.com&#x2F;platform&#x2F;guide&#x2F;pages" rel="nofollow">https:&#x2F;&#x2F;qbix.com&#x2F;platform&#x2F;guide&#x2F;pages</a>
nkingsyover 6 years ago
I have a list of widgets and a button to create a new widget. I don’t want a full page reload when I create a new widget.<p>What are some elegant strategies for handling this with SSR?<p>I’ve used turbo links and found it rather clunky. Haven’t seen a solution that lets me elegantly reuse server side components in JavaScript without going SPA.
评论 #19185390 未加载
arendtioover 6 years ago
I kinda dislike this article. Not because it isn&#x27;t true, but because of the effect it might have on some readers.<p>Yes, building a SPA is not always the best solution, but sometimes I get the feeling that a lot of developers hide behind &#x27;I know how to build good SSR pages and all SPA I have used suck so I will not learn that sh*t&#x27;. If you know how to build a PWA with SEO support, offline+sync capabilities and push-notifications, you will know when to choose what (because of the pain you experienced learning it).<p>If your boss chooses your tech (from the latest buzzwords) and he doesn&#x27;t understand the implications, I am truly sorry for you, but don&#x27;t blame the tech on it (ask your boss for a seminar on &#x27;How to Communicate with Managers&#x27; maybe then he will understand that you are trying to tell him something...).
mduerksenover 6 years ago
To add some use cases where an SPA would be the favorable choice:<p>- Web-tech front-end for an embedded device. The device, which often has very limited CPU cycles, is not burdened by rendering.<p>- Apps that are intended to be running locally and on multiple platforms (e.g. via Electron), as well as in browser.
chimenover 6 years ago
What about separations in teams where designers don&#x27;t mess with backend programmers code? Updates and parallel works on the frontend and backend projects without issues? What about servers that respond with minimal data and consumers that deal only with displaying the received data? Pushing code, re-compiling and restarting webservers all because a button had to be made green or its shadow changed? What about CI&#x2F;CD, automated tests, automated migrations, builders and compilers consuming dollars and energy for that button change?<p>I&#x27;m happy with building SPAs where it makes sense (myaccount&#x2F;admin). The problem is Javascript and its ecosystem but you could very well go with Ember which is stable as...and be relevant for years.
Ericson2314over 6 years ago
Porque no los dos?<p>We pretender enough so if you turn off JavaScript you get old school and if you turn on you get SPA. All the basic widgets are server&#x2F;client agnostic, and we have a combinator to special-case the server vs client code when needed. The types enforce client-specific functionality isn&#x27;t used otherwise.<p>We also have a &quot;DOM puppet&quot; backend which allows everything to be compiled to native code puppeteering browser APIs from a fair. Prerendering, that, and direct JS output all all supported through related typed abstractions. Soon we will compile the puppeteer to WASM too, so we won&#x27;t even need the direct JS output anymore.
oneshoreover 6 years ago
So much of this is because of the mobile &quot;app&quot; craze where -- due to the limitations of mobile app architecture, you had to build a stateful &quot;app&quot; instead of several independent screens with some limited shared state (usually just a token).<p>Native mobile UIs are great, but something as simple as cookies &#x2F; local storage could allow for stateless (or at least less stateful) mobile apps with native UIs.<p>Now, the abomination of hybrid (cordova), or pre-processed (react native&#x2F;xamarin) mobile apps is whole other thing, but often why web apps are translated to SPAs.<p>If we need a mobile app as well, why not use a common code base for web and mobile...
sebringjover 6 years ago
I think a more practical approach is to focus on a generic enough UI toolkit meaning detached from any specific tech stack that will give a feeling of continuity to customers as they move from static pages and SPAs and different flavors of ideas that IT tried along the way. One SPA to rule them all is ridiculous as it doesn&#x27;t work that way with scale as you have independent teams working on various projects that will be hindered by a single approach in that everyone will have to understand x approach and also have stupid meetings about it.
littlecranky67over 6 years ago
There are some features which will clearly call for a SPA over SSR, if you need<p>* to continuously play media (video&#x2F;audio) while the user interacts with the web app (think modern youtube, soundcloud, spotify web, video news sites) * provide offline usage&#x2F;features * highly interactive app with extensive use of drag&#x27;n&#x27;drop, animations, touch events etc. * data sync between browsers&#x2F;tabs (think moving a ticket in a trello board should update the stacks in other open trello tabs or even for other users that currently view the board)
jtmsover 6 years ago
A well written rails app with good caching and some async stuff sprinkled in where necessary generally feels just as responsive as an SPA for a fraction of the dev cost.
PretzelFischover 6 years ago
I have always used SPA for line of business applications. The SPA SEO request seems like a red flag that the wrong approach has been taken.
matchagauchoover 6 years ago
Counterpoint... how many times have you clicked on a <i>Show More</i> link and thought to yourself &quot;No, no... <i>please</i> don&#x27;t redirect me to another page&quot;.<p>Progressive reveal patterns are expected by end users. It&#x27;s just lazy for a programmer to assume old-world CRUD patterns with server-side render.
评论 #19185633 未加载
评论 #19187012 未加载
lloekiover 6 years ago
Not only you probably don&#x27;t need a single page app but you also probably don&#x27;t need a client side lib to build and render your views... Server side view caching and 304 can go a long way and saves round trips, even at scale and is much more friendly to high latency&#x2F;low end cpu user agents.
stevehiehnover 6 years ago
Most of the projects I&#x27;ve been on there is a web app &amp; native apps. So the appeal of a single page app is you will write the exact API&#x2F;auth for all the clients. Would it be tempting to not use the same auth flow&#x2F;api etc if you don&#x27;t use a single page app? Not sure.
stevebmarkover 6 years ago
It&#x27;s 2019 why doesn&#x27;t anyone understand that all search engines can fully index SPAs?
k__over 6 years ago
I simply prefer them because I think their architecture is simpler than some frontend&#x2F;backend mixed HTML stuff.<p>JAM-stack etc. just create static html&#x2F;css&#x2F;js and deliver it over a CDN of your choice, then hook into the services as you need them...
intrasightover 6 years ago
Wait - what other type of application is there? I transitioned to SPAs 18 years ago and would never look back. That is for &quot;applications&quot;. For web sites I would never use SPA. I stick with server-side rendered HTML.
ercuover 6 years ago
For me, the biggest problem with SPA is, needing node.js when you want SSR. There should be better ways than adding another backend layer if your stack is different and you don&#x27;t want callback based multi-threading.
johnchristopherover 6 years ago
&gt; Gulp, CoffeeScript, BackboneJS, and SASS, all of which have been superseded by newer tools. Avoid the Javascript fatigue by not relying so much on Javascript!<p>What ? These are all javascript things, right ?
评论 #19185256 未加载
exabrialover 6 years ago
If latency drives your conversion, then SPA is [probably] not for you.
codeisawesomeover 6 years ago
In “reasons for going SPA on a greenfield project” I would add:<p>- Need for a mobile app is close on the roadma and there is an opportunity to build server code in an API first fashion.
SimeVidasover 6 years ago
You probably need a publication date for your article.
nailerover 6 years ago
The term SPA is outdated and inaccurate ( most web apps have multiple pages) but until the DOM APIs include data binding: yes you do.
zokierover 6 years ago
This is a tangent, but is Github really still mostly ssr? It sure feels more spa-like these days, full with their own loading bar.
评论 #19185523 未加载
评论 #19185436 未加载
sriram_iyengarover 6 years ago
Valid points. - another aspect to consider seriously when designing SPAs is authentication. I have built ReactJs applications and everytime we need a different module that had only the login functionality. Somehow this always appeared disconnected whereas In traditional apps you have a middleware that watches before rendering, be it client side or server side rendered.
sheeshkebabover 6 years ago
Coming from similar background as author (various legacy web apps with all the challenges of learning now useless js frameworks) - I’m now have a different opinion:<p>SPA approach should be the default unless you have specific requirements to add html SSR (and even then google is pretty good at indexing public spa content too).<p>So, respectfully disagree.
评论 #19185198 未加载
Chloroover 6 years ago
I don&#x27;t get it. SPAs are easy to make and have way more pros than cons.
miguelrochefortover 6 years ago
Building a SPA is not more difficult than SSR.
trumpedover 6 years ago
You probably dont need a 40mb app either...
wnevetsover 6 years ago
but how else would I get a job making SPAs if I don&#x27;t make SPAs? &#x2F;s
ilrwbwrkhvover 6 years ago
and if u have to use a framework please use something like mithril
aviatoover 6 years ago
I’m surprised this article doesn’t touch on Next.js at all.
评论 #19186096 未加载
vajrapani666over 6 years ago
The OP glossed over managing styles and i18n between embedded JS apps and the host app. I&#x27;m not sure if there is a way to create strictly isolated CSS in pure server rendered applications without managing naming your own selectors manually. If you build tiny JS apps into your server rendered apps, you&#x27;ll have to keep the styling for the JS app either in the main app, or bundle it into the embededded JS. If you bundle it into the embedded JS, you&#x27;ll end up with two styling pipelines, which could make it more difficult to share variables and constants between the two, if you put the CSS rules for the embedded app in the host app, then you have to change the host app CSS for changes in the child app, which means the two might need to be in the same repo. This gets especially more difficult with advances in UI and interaction design which lean more heavily on state based animation. In those cases, we HAVE to have CSS related to animatable elements that are based on application state within the embedded JS application, then you&#x27;ll really have an issue with having two pipelines. There are similar issues for i18n, asset bundling, accessibility auditing, and testing.<p>Given all the complexity of managing multiple pipelines for simple and complex pages, it seems to make sense to avoid that complexity by adopting a single pipeline that ensures browser compatibility, testing, i18n, accessibility and performance optimizations are consistently applied and centrally maintained.<p>Which might imply , if _any_ of your app requires complex presentation&#x2F;interaction, it might be better to just build the entire app using the same framework.<p>Unfortunately, even if your app doesn&#x27;t currently have complex functionality or interactions, doesn&#x27;t mean you can guarantee it won&#x27;t ever. Investors are known for pushing products to innovate, pivot, and adapt. Which implies that avoiding SPAs is a privilege for app developers and teams who have absolute control over their product and won&#x27;t ever be forced to build more complex products.<p>The Op also doesn&#x27;t address how having frontend dedicated ecosystems might affect hiring, or influence performance. I remember the days of having 20 instance variables set within a rails action and each of them being deeply coupled into the Erb template. Having a clear client server separation at least forces one to use an API, which can make caching easier by separating the caching of presentational and data elements. Also, the semantics of each server side templating language are quite different. E.g , slim vs liquid vs haml vs ejs. Using server side templates requires frontend developers to be much more versed in both templating languages and understanding the tiny bits of embedded server side code. I don&#x27;t imagine too many front end folks jumping to learn scala, clojure or Haskell. However, if the client and server are separate than that means a scala shop can focus on the API and hire a frontend dev with no experience in the server side stack.
nfRfqX5nover 6 years ago
server rendering has a cost too. SSR is not easy. gatsby is mostly solving this in the react space.
tttyover 6 years ago
Normally you&#x27;ll always need to add something interactive, therefore js. To do that with server side rendering you&#x27;ll couple the client side to the server side.<p>For example the server has to send a tag with a class name that the client also is aware of that.<p>Therefore you have 1 component, where half is on server side and half of on client side, which in my opinion is not maintainable.
评论 #19184731 未加载
评论 #19184674 未加载
评论 #19184669 未加载
fxfanover 6 years ago
I need a quick primer on how spa does seo? Do they &quot;server-render&quot; the individual instances of pages too?
评论 #19184829 未加载
评论 #19184704 未加载
评论 #19185560 未加载
评论 #19184709 未加载
评论 #19184701 未加载
评论 #19184699 未加载
patientplatypusover 6 years ago
This feels like clickbait, but just as an aside there&#x27;s nothing that says you can&#x27;t do server side rendering and react. Next.js is what I&#x27;m using on my current project and it&#x27;s server side out of the box. So you have text rendered in source like you would with a traditional server side app with the benefits of SPA. So at least one of his nitpicks sounds like he didn&#x27;t do his homework.
评论 #19184719 未加载
kadendogthingover 6 years ago
Yes you actually do. At the very least you should build your web app with technology that makes it fairly trivial to move over to an SPA.<p>MVC is a mistake. Read that again. MVC is a mistake. It&#x27;s not a good paradigm to write web applications in.<p>SPA&#x27;s are not complicated. They do not take longer to build. They defacto are often way more responsive than any server side monolith that gets built. Because developers who buy into an archaic and broken &quot;MVC&quot; systems typically do so because its &quot;easier&quot; for them, but it&#x27;s easier because they&#x27;re not willing to think about whats being written in the first place, and that&#x27;s a recipe for a bad app no matter how you write it.<p>Inevitably you will end up hacking your &quot;simple&quot; MVC app to meet perfectly reasonable, ubiquitous client requirements regarding user experience. Because the paradigm isn&#x27;t fit for base level requirements.<p>A few years ago my entire job was completely based around consulting for these types web applications. Inevitably you get these developers that think they&#x27;re wise by going &quot;we&#x27;re just going to do it with MVC&quot; -- and after a few months of use it becomes completely obvious that the dev team can&#x27;t meet any kind of modern requirements for the web application. The existing web app is slow (but it&#x27;s &quot;fast&quot; to the developers), buggy, and the worst part for the business is it takes forever to write features for. Eventually these companies get so frustrated they look to the outside.<p>To recap, when you build a &quot;traditional&quot; MVC app this typically means a few different things:<p>1) It&#x27;s written in a toolchain that&#x27;s fairly niche to &quot;back end&quot; developers; severely limiting the pool of talent that company can hire to maintain the web application moving forward. In a fair number of cases the company will have a front end team and a back end team. And sometimes all that back end team does is update views so the JS developer can do their thing. So expensive for something so small.<p>2) You will end up writing a mass of JS anyways, but the JS will mostly revolve around dealing with the fact that the server side templating language controls the original output of the web application. At worst, this means that a lot of devs like to sprinkle bits of HTML inside the JS. So now your templating is strewn across multiple languages and locations. The JS is typically bad because these are &quot;real&quot; developers who don&#x27;t like JS.<p>3) Because of 2, there will also be a mess of server side code purely written to massage data into the server side templating language and an analogous set of code just for the JS side of things.<p>4) Because of 2 and 3, the app because buggy and oddly slow (though again, the devs that wrote it will only look at the original output timing and not the actual life time performance of the application).<p>5) Because of all of the above, the company has now spent an enormous amount of resources for a fairly shitty app that no one likes to use nor maintain.<p>My primary focus for these companies was to build a baseline SPA. And then over the next couple of months guide them through creating new features.<p>And this wasn&#x27;t a one off thing. I had an entire job based around fixing the sins of the company&#x27;s internal developers who are costing the company money while not delivering, costing the company money making the application way more complicated than it needed to be, and costing the company money by forcing the company to hire a specific subset of developers familiar with their MVC toolchain.<p>Stop circle jerking about MVC apps. They were ugly in the first place and continuing to claim that&#x27;s how we should build web apps is an erroneous position purely fueled by stubbornness on the part of developers.<p>Here&#x27;s my benchmark for an SPA: You can either build your entire site using static generation, or you need to structure your web app as an SPA (or prepare to do so in the original implementation). That is the threshold in the current landscape. If you can&#x27;t get away with doing a statically generated site then you&#x27;re not going to have fun writing your site with backend MVC framework. At the very least the company&#x27;s finances definitely won&#x27;t.
评论 #19186948 未加载