Live data from Hacker News

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

goiabada.blog

71–80 of 97 posts

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

#71

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…

[deleted]

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

#72
post #8

From my point of view SPA and solid backend APIs go hand in hand. I see the main reason to use a SPA is to decouple front- and backend. Doing so allows you choose a new frontend after some years while keeping the backend - or rewriting performance critical backend code while reusing the frontend. Do you think the SPA-ish look and feel really is the key? That would surprise me. It is more of an architectural design ch…

Your front end web server can call your backend API, so you can decouple without it being SPA.

Correct, but its arguable which will be more work, with a front end server and backend API you are still writing two applications, and most probably, you still need to sprinkle some JS for UX enhancement.

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

#73

I know they are trying to promote their own Front-End Framework (while trying to pretend that it isn't one), but with regards to the question on the title, my experience is: you can, but please, don't. It actually isn't THAT hard, but what will happen is that you'll end up reinventing the wheel badly, and you'll be chasing bugs and fixing platform inconsistencies for months. It won't be optimized and it won't work in…

Turbolinks is not a front-end framework. It is a library that has been in Rails for ~5 years. And before that, pjax did basically the same exact thing. This is a pretty battle-tested way of building web applications.

GitLab removed TurboLinks from their site not that long ago. It was the source of a lot of bugs, crufty code, and flakey tests. If you have any JavaScript that modifies the DOM or ever plan to don’t use TurboLinks.

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

#74

Turbolinks is OK, but I prefer intercooler for HTML-based apps because it gives me a lot more control: https://github.com/LeadDyno/intercooler-js/ I don't use it for everything, but it's great for a lot of my work.

I've experimented with Intercooler, and it's a nice intermediate step between just enhancing a site with some jquery or vanilla JS and full-fledged SPAs.

This is almost a general theme in webdev, the middle ground is often left out, with things accumulating either on the complex or purposely minimalistic. Rails/Sinatra, Flask/Django, React/Angular... (and yes, I'm aware that it's slightly ironic that RoR is now my "monolith" end of things, given how light it was back when we were doing horrible things with Struts and J2EE)

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

#75

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…

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.

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

#76
post #74

Turbolinks is OK, but I prefer intercooler for HTML-based apps because it gives me a lot more control: https://github.com/LeadDyno/intercooler-js/ I don't use it for everything, but it's great for a lot of my work.

I've experimented with Intercooler, and it's a nice intermediate step between just enhancing a site with some jquery or vanilla JS and full-fledged SPAs. This is almost a general theme in webdev, the middle ground is often left out, with things accumulating either on the complex or purposely minimalistic. Rails/Sinatra, Flask/Django, React/Angular... (and yes, I'm aware that it's slightly ironic that RoR is now my "m…

I hadn't thought of it in those terms, but I definitely agree. I also like that I don't have to decide up front that I'm going to write my whole app using it and can add it in later on where it makes sense. I don't know what to call that, but it's nice.

I wouldn't try to write a video game or anything like that with it, but for most of what I do it gives me what I want with very little complexity.

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

#77

Earlier quoted context omitted.

Turbolinks is not a front-end framework. It is a library that has been in Rails for ~5 years. And before that, pjax did basically the same exact thing. This is a pretty battle-tested way of building web applications.

GitLab removed TurboLinks from their site not that long ago. It was the source of a lot of bugs, crufty code, and flakey tests. If you have any JavaScript that modifies the DOM or ever plan to don’t use TurboLinks.

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

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

#78
Discussion about frameworks and SPA focuses on developer convenience, but it's necessary to look at user happiness. Is the bloat of the modern web a necessary consequence of big frameworks or a result of incompetence? That is, are people just bad at using them?

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

#79
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.

See, you don't always need a SPA, you know.

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

#80
post #66

I know they are trying to promote their own Front-End Framework (while trying to pretend that it isn't one), but with regards to the question on the title, my experience is: you can, but please, don't. It actually isn't THAT hard, but what will happen is that you'll end up reinventing the wheel badly, and you'll be chasing bugs and fixing platform inconsistencies for months. It won't be optimized and it won't work in…

Turbolinks evolved from Pjax (4 yrs old) and is part of Ruby on Rails (11 yrs old). Not only does it respect back/reload out of the box, but it also supports native. Its as mature as it is supported as it is powerful. It really just works - drop it into a project and you instantly have a SPA. Its far from a framework - its API has less surface area than even React. The above comment couldn't apply less to Turbolinks.…

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