Hacker News new | ask | show | jobs
by myf01d 3503 days ago
I am sorry if this sounds too ignorant, are frameworks like Vue.js (I actually read the guide and understood some wonderful things about its philosophy since I am actually developing backend mainly) or React, etc.. reasonable to use in websites in general (instead of jquery or taking some tasks from it) or they actually only reasonable for mobile web applications and SPAs?

What about the SEO and search engine rendering to custom HTML elements like in Vue.js components? is it okay or affects SEO?

10 comments

I can't speak to Vue, but React is overkill for many sites. The virtual DOM etc is incredibly useful for sites that update the page very frequently, but if the only thing you're making is a static site and a contact form, you don't need React.

That said, I do like the React model of creating components (and suspect this is why so many people use it when it's unnecessary). I'm looking forward to browsers implementing custom elements so that we can all compinentise this way without the overhead of a large JS framework.

While the virtual DOM is a component in React's popularity, the main thing that I believe people use it for is the functional, one way data flow it allows you to use combined with the component model.
Chrome, Safari, and Opera (because of Blink) have implemented Custom Elements and Shadow DOM. Firefox appears to be working on it, and for Edge it's high priority, so things are coming along nicely :)

edit: The polyfills are also very viable. I know sometimes people knock polyfills, but they're really just libraries that implement the component model and encapsulation that frameworks generally have to, but they go away over time.

Not in websites per-se, but even the simplest contact/enquiry web form/wizard with some validation/interaction is a breeze to program in Vue.js compared to jQuery.

We have multiple internal enterprise applications where both jQuery and Vue.js are available. More often than not, when there's a pull request, even for the simplest UI interaction, it can be refactored to few lines in Vue.js from the jQuery event and DOM mess. We plan to move away from jQuery in a year or so, and no new jQuery plugins are allowed.

Vue.js has also allowed us to iterate much faster on complex UI than it would be possible with jQuery.

For bigger apps, you can add components, and for even bigger - add Vuex. Vue.js (same as React) really is the new jQuery.

From personal experience for general web-sites like blogs, etc. it's better to do them old way, you don't need to worry much about seo, caching, precompilation, etc. But business apps huge community-like ones, and big shops benefit a lot from frameworks like that. But you should always base your decision on cost of implementation, support, etc.
Thanks, I am more interested in developing social websites with modern look and more performance, I mean like the design of medium.com or hashnode.com, I think they do render the first page fully canonical HTML, and then every subsequent request is rendered using the js framework GETing some JSON which gives more space to the server to do other work.

I am really interested in this approach but I fear about the SEO and any additional unnecessary complexities like compatibility with old browsers and OSs especially in Android.

Take a look at russian vk.ru

It's lighting fast compared FB and does all the same things. Really neet. FB makes my laptop literally over heat.

If you fear about the SEO, start with Turbolinks.
React in particular, however, was specifically made to handle the state of just parts of the UI on Facebook (like notifications). You could build out a static site but let React handle something more complicated and it'll work just as fine, if not better.

It just so happens that the extensibility around React led to stuff like redux and react-router that's perfect for SPA's, but at its core it's just a View layer that could live alongside a traditional site.

Both Vue.js and React allow you render HTML on the server side. This helps get the first render out quickly where the browser can pick up the state and continue from there.

https://vuejs.org/v2/guide/ssr.html

As it usually is in this industry, the answer to this question is: "it depends".

There's a point, where using jQuery alone just won't cut it.

I guess a rule of thumb here would be: If you're providing a service that requires an account - you probably need something more than jQuery.

In vue.js, SEO is taken care of with with server side rendering[1].

This assumes that you are using node.js as your backend though.

[1] https://vuejs.org/v2/guide/ssr.html#SEO

Only that node can talk to your backend right?
I haven't heard of Laravel getting SSR yet, so yeah.
What I like about Vue is that it makes it is very easy to use it as a component of a larger website or non-SPA application. You can use it where you would otherwise use jQuery in order to build widgets or interactive components. It makes it very easy to drop it into a page without a lot of ceremony (no flavor of the month build tools or exotic precompilers are required to get started).
What would be better o build in terms of code clarity, performance and some other var I can't thin of rn, a slideshow in JQuery or using Vue.js?
In the past I've used https://prerender.io/ with a Backbone + Marionette website. You configure your .htaccess (or similar) to direct web crawler's to prerender.io's cached representation of your website. Works great and completely side-steps the issue of SEO for dynamic websites.
Google will index sites that render their pages through Javascript. There are two caveats to be aware of:

1. It drops out if it takes more than 5 seconds to complete its operation and uses whatever is render then.

2. Indexing with HTML happens in near-realtime. Indexing with JS to HTML is delayed by about 1-5 days depending on the popularity of the site.

So if you're serious about it; you ought to heavily include metadata for Google to index during the first run through or place a bare bones HTML copy down.

Proof?
I can't find the article yet, but a few months ago I read that only some chinese search engines had problems with that. The big ones didn't care much.