4

I am starting a new project and trying to decide if I should use a Javascript framework (like vue.js or react) and create a Ruby on Rails API, or use Ruby on Rails to server-side render pages and sprinkle javascript on to the pages (potentially leveraging Stimulus.js).

I am currently very comfortable using RoR to generate a web application and have only recently started looking at using a JS framework.

My question is, what benefits do you get from using a JS framework, vs server-side rendering? I'm having trouble defining a line for when client side should be used compared to the server-side rendering.

For instance, in poor internet connection environments, does client-side perform better than server-side rendering? My assumption is that because all the data is called on initial load of the page, it allows for the application to run client-side with little to no internet access until the need to persist something to the DB is required.

I believe I understand how the basic implementation and flow works for Client-side rendering, but I am unsure why we need it and what benefits it provides over server-side rendering with javascript.

Thanks,

  • 2
    JS frameworks are not mutually exclusive of server side rendering (i.e. Bootstrap or Foundation). That said, Single Page Apps (SPA) change how you think about designing your application. I.e. sessions are essentially controlled in the client rather than the server. Angular and React are typically tools used for SPAs. There's no cut and dry answer here. – Berin Loritsch Apr 26 '18 at 16:22
  • 1
    The reason for the downvote (not mine) is that your question is too broad. I agree. I suggest doing some research on single page apps to understand the why's and benefits, as well as the complexities that come along with that approach. – Berin Loritsch Apr 26 '18 at 16:24
  • 1
    Client-side rendering provides highly-interactive capabilities in the UI that server-side rendering alone cannot provide. See en.wikipedia.org/wiki/Fat_client. – Robert Harvey Apr 26 '18 at 16:47
  • 1
  • 1
    React and similar SPA technologies reduce the server side to a set of REST calls that send and receive JSON. You can deploy your fat client as a set of flat files in AWS so there doesn't need to be any dedicated server to host it. Since state is stored on the client, you can avoid sessions in the server which allows you to scale up and down simply by adding instances behind a load balancer. But there is a very high learning curve. If you go that route you'll want to be able to have some sort of group you can chat with. My company has in house expertise. – Berin Loritsch Apr 26 '18 at 20:17
5

As with any other question to adopt a technology - it depends on the technology. It depends on your requirements. It depends on any future requirements/the roadmap for the product. It somewhat depends on the various skills in your team too.

Broadly speaking (very broadly), JS frameworks will do the heavy lifting when it comes to binding your data to your mark-up. You, typically, have a model of data, and you have some mark-up to which you'd like to bind it. You can achieve this in JS yourself if you wish, but a framework will cater for it most of the time.

Some JS frameworks also deal with routing to help with the notion of a 'single page app'.

There are many more advantages, specific to the framework.

That said, I am very conscious of the impact a JS framework can have when it's overkill. Not only is there a period of time when your developers may need to skill-up and gain some experience in order to get the most out of the framework, but a framework can often enforce, or at least encourage, you to work within it's paradigm and conventions - whatever they may be. Not necessarily a disadvantage, if you require that structure in your solution (which is why I'm mentioning it in response to 'advantages').

I'm having trouble defining a line for when client side should be used compared to the server-side rendering. - run through your requirements and, maybe as part of the estimation process, think in a little more detail what your approach would be to tackling them. If you find yourself reinventing the wheel based on what a JS framework can offer, then go for a JS framework. If you're unsure what a JS framework can offer, look into them more. Sounds like you've chosen some good frameworks as a starting point for research.

2

There are several benefits to use client side JS over server side. One is it scales easier than server side, another is its ability to render faster since it doesn't have to send data between client and server that often as a server side solution need.

On the other hand, a heavier client takes longer to load in the beginning, especially over poor network. It really depends on the intended audience, and what network they usually have.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.