Live data from Hacker News

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

goiabada.blog

91–97 of 97 posts

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

#91
post #87

Actually the first thing I do nowadays when I start a new project using rails is turn off turbolinks. Rails has so many "magic" hidden underneath and Turbolinks is the epitome of this problem. I have no idea how it works, but all I know is it breaks my apps too often if I ever make use of a lot of JavaScript code. Nowadays I do: 1. Pure old school websites with no SPA approach (Surprisingly, most web apps work just f…

Turbolinks isn't that complicated. You should spend a day or two to learn it. Definitely useful in for #1. Depends on what you want to do for #2.

I guess I should have clarified.

I just don't like how it does things I don't want it to do, because when I'm using rails + simple javascript, there's a reason why I'm doing that instead of API + frontend JS framework SPA approach--I WANT it to work like a website, with full page refresh and all.

And I would like to say, for most use cases this is actually much better user experience than trying to make it work as SPA because users want to see "clear cut answers" to their actions.

This used to be simple when web pages just refreshed, but with single page apps, there are so many points of failure that you have to build all kinds of middleware just to make sure this type of client/server inconsistency doesn't happen. And I think this is overkill. Most people have been using regular websites just fine, and even when I've built tons of SPA for living, I myself still prefer regular web pages, you know, like hacker news. It's simple and it works. No state inconsistency, no memory hog.

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

#92

Earlier quoted context omitted.

As a counterpoint, Turbolinks has been an unmitigated success for a huge app that I work on. 80% of the performance and responsiveness of an SPA with about 5% of the work. Granted, the app is very vanilla-Rails. I can see Turbolinks getting in the way if you have a bunch of other "complicated" Javascript, but if your app is mostly standard Rails views plus some jQuery, Turbolinks is an amazing hack.

Yes, but my point was that if I want my app to be "vanilla rails with jQuery" (which actually is all you need for most web apps), I actually WANT it to behave like a "website", meaning I DON'T want it to behave like a single page app because it's confusing both for users and the developer (myself), which is where turbolinks comes in.

IMO, it doesn't behave like a single page app. It just performs like one (aka, it's fast as heck).

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

#93
post #77

Earlier quoted context omitted.

Shopify went back to Turbolinks: https://shopifyengineering.myshopify.com/blogs/engineering/r...

That article is from 2014, the golden age of TurboLinks. As far as I can tell they are not using it on their main site or any of their white labeled sites anymore. https://github.com/shopify-graveyard/turbolinks/

They forked: https://github.com/Shopify/turbograft to add partial page replacements. It was slated to be merged in TurboLinks 3 but that canned in favour of version 5.

Their new Polaris components are using React though: https://github.com/shopify/polaris

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

#94
post #81
post #80

Earlier quoted context omitted.

The only true caveat is you can’t have multiple dynamic elements per view.

It allows you to do partial updates, but indeed it doesn’t support view transitions out of the box. :/ That said, the native wrappers offer built-in transitions, and you could probably hack web transitions with some modding and a component library.

I like your optimism, but I would like to remind (scare) you:

If you decide to put your effort into customizing the framework, you increase your risk of building

> [...] your poorly cobbled-together "framework" for the next 2, 3, or more years. If anything changes and pages stop working "right", you get to pick up the pieces. Yes, "you", because since your framework is something that you pieced together, there are no "tutorials" nor stack overflow questions nor manuals to refer to.

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

#95
post #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?

They're working on more important stuff ;)

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

#96
post #87

Earlier quoted context omitted.

Turbolinks isn't that complicated. You should spend a day or two to learn it. Definitely useful in for #1. Depends on what you want to do for #2.

I guess I should have clarified. I just don't like how it does things I don't want it to do, because when I'm using rails + simple javascript, there's a reason why I'm doing that instead of API + frontend JS framework SPA approach--I WANT it to work like a website, with full page refresh and all. And I would like to say, for most use cases this is actually much better user experience than trying to make it work as SP…

Interesting points. Hasn't been my experience Turbolinks does anything I don't want since Rails5.

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

#97
post #86

Earlier quoted context omitted.

> GitLab removed TurboLinks from their site not that long ago. It was the source of a lot of bugs, crufty code, and flakey tests. An anecdote is not data.

> Turbolinks.clearCache() Removes all entries from the Turbolinks page cache. Call this when state has changed on the server that may affect cached pages. https://github.com/turbolinks/turbolinks#turbolinksclearcach... This is a nightmare. You will eventually miss a cache invalidation and break browser navigation or invalidate the cache so aggressively that TurboLinks is serving no purpose. You don't need lots of neg…

Haven't had any problems with this in 2 years in production. It also works fine for Basecamp.
Post reply on HN