Live data from Hacker News

Turbolinks: SPA-like Experience without the SPA-framework Hassle

goiabada.blog

41–50 of 97 posts

Re: Turbolinks: SPA-like Experience without the SPA-framework Hassle

#41
post #12

The title is misleading since this is basically a TuboLinks article and doesn't really explore the problems of building an SPA without a framework.

Agreed. TurboLinks itself seems unnecessarily heavy. So you avoid a full page reload, but you do still have to fetch the whole page over the network and render it. Just without the browser loading icon spinning.

Well, you can use data-turbolinks-permanent to prevent turbolinks from trashing a dom subtree, so that lightens it up a bit. Its also often paired with caching so that big chunks of the page are pulled from the cache so you can often do a sub 300ms refresh of the page with turbolinks while working well on slow mobile connections that choke on large js bundles.

It is complex in its own way though, so there's no free lunch here.

Re: Turbolinks: SPA-like Experience without the SPA-framework Hassle

#42
post #6

I don't think you'll find anyone who thinks it's hard to build 1 SPA without a framework. The thing is that if you build 2, 3, 100, you'll find yourself doing the same stuff over and over again (and always better than the previous time, so that you'll want to replace all your old code, which is now obsolete), and that's when frameworks are useful.

so that you'll want to replace all your old code, which is now obsolete), and that's when frameworks are useful.

You know, like Angular 1.

Re: Turbolinks: SPA-like Experience without the SPA-framework Hassle

#43
It’s the wrong question to ask. Frameworks exist so that devs can stand on the shoulders of wheel reinventors/optimisers, and perhaps more importantly debuggers. If you’re going to build an SPA, you may as well use a framework.

The question to ask is: should you build an SPA? Many complaints we as developers have, especially regarding browser history issues with SPAs, are issues that the end-user also experiences, but under the umbrella classification of “the website doesn’t work well.”

An SPA offers much in the way of developer ergonomics, but does it benefit the end-user? I’m inclined to think it doesn’t in many cases. Aside from the issue of downloading Javascript libraries, SPAs often make the user experience unnecessarily jarring when even simple things can seem to take longer because the browser is hanging while JS occupies the main thread — which, in the end, is at least on the same level as a full page refresh, in terms of user experience.

Of course, I’m no UX expert, but speaking from my own experience and the experience of some non-developers with whom I communicate, I have concluded that web applications which do the bulk of the work server-side and emit fully rendered HTML without the need for Javascript libraries etc. tend to offer preferable experiences for end-users.

Obviously React blurs the line a little with server-side rendering, but it's rare that you see a truly well-executed example in the wild. Maybe I'm wrong, I don't have a good sample size to make remotely objective conclusions.

All I know is that Github is a website that works very well (in my opinion) and its full page refreshes never bother me. Same goes for a handful of other websites (FreeAgent, an accounting platform, was also very nice to use when I was a freelancer). I just can’t shake my scepticism about SPAs as a result, despite the fact that working on them comprises my profession, my every day life.

It makes me miserable sometimes though, to feel dubious about the things I help build day after day, but I don't have the luxury of being able to just build what I want, I need money so I build what others want.

Re: Turbolinks: SPA-like Experience without the SPA-framework Hassle

#44
post #26
post #16

Downvoting everyone answering the title question and not reading the article. You guys should be better than this. It's not about cowboying or NIH. It's about using a library called Turbolinks https://github.com/turbolinks/turbolinks to render static pages server-side and swap the content out with js.

> Downvoting everyone answering the title question and not reading the article. You guys should be better than this. Downvoting you for not paying attention to why people are answering the title question--because it was the title question in the article, which then proceeded to answer a different question. > It's about using a library called Turbolinks Which is not answering the title question of the article. The art…

> Downvoting you

Which is fine. All contributions not engaging the content should be pushed to the bottom of the stack for the more interesting discussions to bubble up.

> because it was the title question in the article, which then proceeded to answer a different question. > Which is not answering the title question of the article. The article should have been titled "Build a Single-Page Application Using Turbolinks".

Clickbait is exactly why we should be dissecting the article and ignoring the title. Flag the submission if it's that offensive, even. Answering the clickbait question is just noise.

> Even the part about "without a framework" is false: Turbolinks is a framework.

Of course it is. I expect people to call that out as well as clickbait, but that's kind of bikeshedding. What's far more interesting to discuss is the approach: pre-rendered html dynamically swapped vs SPA's, tradeoffs, pros/cons, performance, security, etc.

Re: Turbolinks: SPA-like Experience without the SPA-framework Hassle

#45
post #33

Hmm, my backend is some SQL, a bunch of PHP scripts handle requests and return JSON to my SPA. Only thing I use is jQuery since I didn't want to handle the FX stuff; everything else goes through some wrappers I wrote in half a day and which take care of browser glitches. JSON to html5 content is now at a few thousand SLOC, but still easy to maintain - by me, but honestly not by others. Would it be better with a frame…

If you have some OCaml masters, why not slap together some BuckleScript to call an simple OCaml wrapper around the sql and call it a day?

Re: Turbolinks: SPA-like Experience without the SPA-framework Hassle

#47
post #17

If you are not on a team and don't have any budget requirements, then sure. Do it all from scratch and in your own arbitrary flavored-way in your basement, then write documentation later and put it on hacker news as the next great js framework to use out of plethora already there, then someone writes an article like this and places it on hacker news, then repeat the process again.

I think we've had some of this on the backend too. I've seen "you don't need a framework" a few times outside of the current JS atmosphere. Seems like the easier it is to get going, the more frameworks you'll get. PHP is similar - a good whack of frameworks. The community has banded together, producing a group of developers, one from each major library or framework just so they can figure it out. It's called the Fram…

That’s one of the reason I prefer libraries to franework and if at all possible core libraries get wrapped in access objects or delegates abd such - a library can be replaced if it gets discontinued or some issues arise down the road, a framework intwrtwine with your code too much and it’s a risky proposition for anything you plan to maintain for more than five years, i.e. devs who bet on angular.

Don’t get me wrong I like the react structure for example and I see the value in having the whole foundations laid out and a strict structure to follow and they seem stable enough for a project, but there’s no way to use it and still maintain control over your code, they become one and if anything happens it’s either a rewrite or one of the purported drop in replacement or you have to get in the code or provide a bug report and wait for a release... and all that is incompatible with enterprise softwares with a sla.

Re: Turbolinks: SPA-like Experience without the SPA-framework Hassle

#48
post #12

The title is misleading since this is basically a TuboLinks article and doesn't really explore the problems of building an SPA without a framework.

Thanks, we've updated it to a representative phrase from the article. We can change it again if someone suggests a better one.

Re: Turbolinks: SPA-like Experience without the SPA-framework Hassle

#49
Sure. I build them all the time. It's dead simple as long as you keep it simple.

I'd argue that the bigger problem is knowing when you need an SPA. Every website thinks they need an SPA, even when they obviously don't. Your news site doesn't need to be an SPA, your document-sharing service doesn't need to be an SPA, your movie recommendation service doesn't need to be an SPA, etc.

Re: Turbolinks: SPA-like Experience without the SPA-framework Hassle

#50

No. You can build one without using a framework that someone else wrote, but you will inevitably end up with an ad hoc framework of your own design.

If that's the case every program ever contains a framework. That would be quite an useless definition.

I assume that it depends on how general the internal code is. If it's very specific it's not really a framework. Of course people often forget about YAGNI principle and end up with an ad hoc framework.

Post reply on HN