News for hackers. Stuff that matters.
Re:Advice to Young Web Developers by timw4mail on Thursday June 18, 2020 @03:22PM (#23566701)
SPAs are an anti-pattern.

Let's rebuild html rendering, navigation history, forms, etc, all with Javascript, because it's the hip thing to do.

Re:Advice to Young Web Developers by Kaze404 on Thursday June 18, 2020 @03:33PM (#23566862)
There are very clear reasons for SPAs to exist.

1) Prevent reloading of the page every time the user clicks a link, reducing the overhead of fetching common content between pages multiple times (headers, menus, etc) and providing a more seamless experience to the user.

2) Better emulate the feel of mobile applications, for users who spend most of their time on their phones and don't often or have never interacted with a computer. Yes, those exist.

3) Improved network performance (by sacrificing initial load time). Once the browser downloads and caches the bundle on initial load, the user can revisit the page on regardless of their connection stability or speed.

This isn't to say SPAs are a perfect choice in all cases (they also have just as clear drawbacks), but saying "it's what everyone does" is the only reason they exist is downright false.

Re:Advice to Young Web Developers by randompwd on Thursday June 18, 2020 @04:09PM (#23567387)
> Prevent reloading of the page every time the user clicks a link,

You don't need a SPA for that. And page load/render times are much shorter when html is delivered straight to browser fr most applications

> Better emulate the feel of mobile applications,

That's pretty weak defense.

> Once the browser downloads and caches the bundle on initial load, the user can revisit the page

Giving we're now in the world of Continuous Deployment, I doubt the cache lasts long.

All 3 of those reasons sound very reaching to me.

And here's the kicker - doing a SPA well enough to be seamless and performant is hard enough that most sites suck if they're delivering a SPA.

Also, if, for example, you do your payments or other sensitive pages in a SPA, you're still running 3rd party scripts on those pages for no reason. Let me know when unloading scripts(&their in mem code) is doable.

Re:Advice to Young Web Developers by shreddish on Thursday June 18, 2020 @10:49PM (#23570495)
> Also, if, for example, you do your payments or other sensitive pages in a SPA, you're still running 3rd party scripts on those pages for no reason. Let me know when unloading scripts(&their in mem code) is doable.

Are you legitimately worried about unloading third party libraries into memory on the browser??

Re:Advice to Young Web Developers by randompwd on Friday June 19, 2020 @06:03AM (#23572900)
unloading third party libraries _from_ memory.

or else gaining the ability to freeze their code and all derived/generated code from accessing the dom/network/etc.

Re:Advice to Young Web Developers by Kaze404 on Thursday June 18, 2020 @05:39PM (#23568352)
Few things annoy me more in this world than when someone "responds" to arguments by quoting half of them to construct and attack a strawman instead of the argument they're supposedly discussing.

Please don't dilude conversations like this, it doesn't do anyone any favors.

Re:Advice to Young Web Developers by Grimm1 on Thursday June 18, 2020 @03:26PM (#23566764)
You're not using that word correctly, since this is not a pattern it's an architecture.

Please don't misuse words, especially in a negative context to mean "something I don't like", it cheapens the word in legitimate cases.

No comment on whether SPAs are worth anything though, I reserve my opinion.

Re:Advice to Young Web Developers by arkis22 on Thursday June 18, 2020 @07:38PM (#23569374)
architecture doesn't contain patterns? architectures don't follow certain patterns?

you've never seen certain architectures that smell because they're not following an established pattern?

Re:Advice to Young Web Developers by timw4mail on Thursday June 18, 2020 @04:03PM (#23567313)
So, it's an anti-pattern of an architecture.
Re:Advice to Young Web Developers by osrec on Thursday June 18, 2020 @03:35PM (#23566897)
The way in which we consume and deliver via internet has moved on from the early days of the web. It's no longer just text, images and links. There's much more to it now, and SPAs are a reasonable step forward to providing richer experiences online with more functionality.

Not sure you could ever call them an anti-pattern.

Re:Advice to Young Web Developers by timw4mail on Thursday June 18, 2020 @04:15PM (#23567461)
> It's no longer just text, images and links.

Assuming you add video, 99% of the web is just text,images,links,forms, and video. None of these things even require Javascript.

Re:Advice to Young Web Developers by osrec on Thursday June 18, 2020 @06:20PM (#23568786)
I'd say a big part of the web is gaming, chatting, interacting. A lot of that content updates every few seconds. Without JS, websockets, ajax requests etc, do you suggest users load the entire page again whenever they want to see an updated view?!

Or is your opinion that it should only be possible to do those things in native, purpose-built apps? Because in that case, how do you justify using an operating system? Perhaps we should exclusively use purpose-built assembly code that you flash to some writable media every time you want to run a particular program!

Re:Advice to Young Web Developers by timw4mail on Thursday June 18, 2020 @06:48PM (#23569008)
As another poster said: The right tool for the right job.

Also, a SPA is not the only option with Javascript.

Re:Advice to Young Web Developers by chipotle_coyote on Thursday June 18, 2020 @04:45PM (#23567806)
How would the site we’re communicating on right now be improved if it were rebuilt as an SPA?
Re:Advice to Young Web Developers by osrec on Thursday June 18, 2020 @06:15PM (#23568740)
Threading could be clearer. Less data would need to be loaded on each page load. I can imagine that a lightweight SPA to handle the a few standard views (e.g. listItems, itemDetails, profile, changePassword, submit) would cut down data transfer by a significant margin (20-30%, maybe more). The UI could also be much better on mobile, and we could give users the option to cache certain pieces of content offline.
Re:Advice to Young Web Developers by ptx on Thursday June 18, 2020 @08:49PM (#23569845)
Offline use already works great, unlike in any SPA I've ever used.

1) Load the page.

2) The page is now fully loaded and ready for reading without any need for further network requests.

For even more offline use, try printing it! HN threads work superbly when printed, again unlike most modern sites.

Re:Advice to Young Web Developers by osrec on Friday June 19, 2020 @05:44AM (#23572804)
I don't think printing is a viable solution for most users. I'm guessing most would want to download the comment threads to their phone so they could read them later in situations where connectivity is patchy (eg train/plane etc).
Re:Advice to Young Web Developers by ptx on Friday June 19, 2020 @08:41AM (#23573887)
Right. You can do this now by loading the page in a background tab, leaving the tab open and then going offline. Works great.

Or you could reimplement newsgroups (but with less interoperability) as an SPA, which in theory would work great (once you work out the kinks) but in practice would suffer from all kinds of little issues in the from-scratch reimplementation of everything. For example, printing would probably forever be a wishlist item in the backlog.

Re:Advice to Young Web Developers by runawaybottle on Thursday June 18, 2020 @07:18PM (#23569226)
What you’re suggesting is heresy on HN. It’s true, a little bit of interactivity, fonts/padding/spacing would improve HN. To this day my thumb covers both the upvote and down vote button.
Re:Advice to Young Web Developers by osrec on Friday June 19, 2020 @05:48AM (#23572824)
Yes, the UX on mobile leaves a lot to be desired in my opinion. The two things that are going for HN in its current form is the fact that it's lightweight and fast.

A lot of people think that moving to an SPA would mean killing both those aspects. But the truth is, you CAN have an SPA that is both lightweight and fast - the developer just needs to know what they're doing.

Re:Advice to Young Web Developers by timw4mail on Friday June 19, 2020 @07:35AM (#23573326)
I have yet to see this...
Re:Advice to Young Web Developers by runawaybottle on Friday June 19, 2020 @04:15PM (#23578460)
You can check out nodebb for example, tons of JavaScript and quite frankly it’s a better forum experience than reddit or HN:

https://community.nodebb.org/category/2/general-discussion

Re:Advice to Young Web Developers by yagodragon on Thursday June 18, 2020 @04:28PM (#23567624)
I also love when i visit a website with a simple markup and minimal js. Not everything should be a react/graphql isomorphic SPA, but have you checked NotionHQ[0]? The whole thing is a single page react app. People use it to build wikis, manage projects and even create blogs and job postings. All that using client-side rendering. It doesn't load as fast as hackernews but most people seem to love it either way.

[0] https://www.notion.so/

Re:Advice to Young Web Developers by Nextgrid on Thursday June 18, 2020 @04:51PM (#23567871)
I’ve had the displeasure to use this once at a client and I was amazed that they managed to make text editing lag.
Re:Advice to Young Web Developers by merb on Thursday June 18, 2020 @03:34PM (#23566884)
I've never heard that somebody disliked vmware vsphere as an spa. the older flash one however...
Re:Advice to Young Web Developers by Scarbutt on Thursday June 18, 2020 @03:35PM (#23566896)
You still need js for interactive apps, SPAs avoid the spaghetti mix of html rendering and rendering client side.