interactivated blog

magento & ecommerce

Advantages of Constant Client-Side Operation – Magento 2 vs. Nuxt

Nuxt and Vue (on which Magento 2 is based) work on very different logic principles. Although there are other discrepancies, the primary distinction is that Vue is continually running on the client side, while Nuxt also uses server-side rendering.

Both rendering types come with advantages and disadvantages. It’s up to the developer to decide which method they’ll use and which would fit the situation best. Here are some of the client-side advantages of Vue vis-à-vis Nuxt.

Different Mindsets

As mentioned, Nuxt and Vue use entirely different means of handling logic. Vue is the better option, thanks to its client-side operation.

To begin with, Nuxt’s mixed operation can be the underlying cause of a variety of problems. This is best explained in the simplest of examples – DOM (Document Object Model) elements. Let’s say that you want to select one of the DOM elements immediately after the app is loaded. Whether the DOM is working on the client or the server side, one thing is for sure – Node.js doesn’t support DOM elements.

This is the main reason why Nuxt resorts to using cookies over local storage – without DOM support, the next best thing is cookies. This method, although widely used in the past, is severely outdated these days, which is why Vue is overall a better client-side operation choice.

Yes, the cookies are always accessible and held in local storage, but they can take a while to load, which is a pitfall of server-side operations. On the other hand, you won’t run into this sort of problems with Vue. It’s always running on the client side, which makes things much easier.

An Example

As a developer (or someone interested in development), you can probably appreciate a clarifying example.

Let’s say that you have code that is tasked with managing socket connection. If you are running on-server, updating the DOM on the receiving socket events is out of the question – the server side does not support DOM elements. This “problem” is one that you can work around.

However, speed is critical to modern web development, and you don’t want to find yourself in the tedium of switching things on or off.

Now, if you try doing the same thing in Vue, you won’t have to input any different code. In fact, the code would be the same… or almost, as you wouldn’t need the early-return part. How come? The process has to run on the client side, so there’s no need to check any statements.

The Beauty of Client-Side Operation

Things couldn’t be clearer in this regard. Vue operates exclusively on the client side and Nuxt shuffles between the server and the client.

Although server-side operations do have benefits, let’s explore the client-side first.

Page Reloading

The main advantage of client-side rendering is that you don’t have to wait for your page to be completely reloaded. You don’t have to re-render the entire page if you don’t want to. This may not seem that essential, but if you have a large number of elements, you might want to have one part of the page update instead of the whole thing. This makes the client-side operation method more user-friendly than the server-based alternative.

This is particularly important in instances of slow internet connections. For example, if a user is trying to access your website using data, they will get the benefit of lazy loading, where only small amounts of data are loaded as they scroll through a page.

Speed

You’ve probably heard that client-side operations are faster. This is because templates, business logic, and other data are loaded in entirety. Instead of having to confer with the main server, webpage info is stored locally. As such, you can get a page loaded quickly unless you’re accessing something for the first time.

Feedback

Having more animation might seem resource intensive. However, sometimes advanced animation options can help provide the necessary feedback to a user. The best example is the ability to notify you that the page hasn’t frozen and is working.

Sure, it may not sound like much, but not knowing whether a page is loading or frozen can be very frustrating. This is possible thanks to modern UI frameworks, which aren’t readily available on server-side frameworks.

Easier User Interaction

Let’s say that the user wants to delete an item from their store. The item has sold out, and graying it out would add to the visual functionality of the storefront. Achieving this on the server side is not impossible. However, this action requires extra code maintenance (on both the client and server sides). This translates to labor costs and complications. With client-side operations, all the client needs to do is to gray out an item.

Keep in mind that this isn’t limited to gray-out operations. Any similar update on server-side pages will require extra interaction.

Server-Side Benefits

Some people stick with the server-side of things for primarily two reasons. The first is that more advanced storefronts may require a combination of the two operation types. The second benefit is that static websites are still around, and as long as this is the case, server-side scripting is the better answer.

With client-side scripting, you get a lot of help with SEO. It’s more modern and it works, provided that your users have good connections.

But what if the client’s target group is mostly mobile users? Sure, sticking with Vue will provide better, more dynamic pages. But once a user connects to data, things become tricky. Even more so if they’re loading the site for the first time. This is not an issue with server-side compilation. The page will load quickly and allow you to move around almost instantaneously. This is not something that client-side compilation will catch up to anytime soon.

There are also compatibility issues. As a rule, server-based operations are more robust. Think of it as a giant transport ship. It is slow, difficult to operate, but stable. Client-side frameworks like Nuxt might be modern, quick, and great-looking, but they might encounter browser compatibility issues.

On the other hand, most modern needs dictate readily-accessible and aesthetically-pleasing web access, which is exactly what client-side frameworks like Vue excel at.

Is Speed That Important?

When you think about it, the main benefit of server-side rendering appears to be the speed. Sure, client-side frameworks will get you to a previously visited page faster, but they are significantly slower with a brand-new webpage.

But then again, you have to consider if it matters. Sure, speed definitely matters but what sort of differences are we talking about? Even with client-side operations, you shouldn’t expect more than one second of load time. In fact, even if a device is not connected to Wi-Fi, data is still able to handle it.

Keep in mind that we’re talking about the era of 4G and 5G technology. Unless you’re in the middle of nowhere, you won’t notice too much of a difference between server-side and client-side loading times.

Magento 2 vs. Nuxt

Where Magento 2 is based on Vue, which operates on the client side, Nuxt uses a combination of both. So, why not opt for the latter? It allows you to choose, right?

Not exactly. With Nuxt, you get the benefits of a universal app but without the headaches that a server brings, which is great. Add the auto-update server options, single-file component creation, and auto code-splitting and you get a pretty decent framework.

However, the problem here lies in the fact that Nuxt is more maintenance-heavy. This is not something that an end-user will appreciate. Plus, there are all the other benefits of client-side compilation.

You can’t use Nuxt as a client-side-only option. It requires a mixed server- and client-side use. With that said, Vue is popular but not ubiquitous.

Which One to Go with?

If you’re looking for a dynamic webpage solution, Vue (Magento 2) can be a brilliant choice. However, even if you expect your clients to try and access your webpages using data, you’re probably better off with Vue as well. Still, you’ll want to consult with the experts and work with them to find the perfect solution for your needs.

By interactivated • on July 30, 2020

Contact Us
Get in touch with a specialist
THE NETHERLANDS (HQ)
Herestraat 106, 9711LM,
Groningen (Netherlands)
+31 (0)50 711 9940
VAT: NL 852998521B01
Chamber of Commerce: 58348646
UKRAINE
Kostomarivs'ka 13,
61002, Kharkiv
SPAIN
Calle Jabea 18, 29631,
Benalmádena Costa (Malaga)

* Required Fields