magento2-knockout

Magento 2 Knockout to be deprecated

magento2-knockout

Magento 2 Knockout to be deprecated

MeetMagento New York took place this month and Anton Kril(Magento Director of Architecture) casually mentioned that the current Knockout-based frontend would be deprecated in favor of the new PWA frontend. It stirred up some things in the community. People were shocked. My reaction: Well, … why be surprised?

Recap of the current frontend

End of 2015, Magento 2.0 was released and since then, frontend developers have been bashing it: The inclusion of jQuery was labeled a main feature, while most frontend devs already saw jQuery as outdated. KnockoutJS was included, while seen by many as deprecated. RequireJS was still a popular feature, but you could use imports and then transpile with Babel, so why all that trouble?

Additionally, Magento had added numerous JavaScript libraries on top to glue everything together, making things unreadable (KO observable linking, to name one ugliness). On top of this, the JavaScript layer was just one piece of this complex puzzle, that also included XML layout, Block classes, PHTML templates. And LESS.

Magento has listened to our feedback

Some frontend developers did not like this frontend. Nowadays, most frontend developer don’t like it. However, since the very beginning that the Magento core developers started listening to this feedback (around Magento 2.0), there were plans to make things easier. Magento started to focus more heavily on JavaScript patterns, modern tools, headless. There were hackathons, DevExchanges, Contribution Days.

Magento listened to our feedback. We were complaining about the old M2 frontend, we are getting a new M2 frontend. This is something to be excited about, regardless of whether you are ready for it.

It was to be expected

In 2017, the plans of PWA Studio were shaped: Around the summer of 2017, it was evident something needed to change radically. A choice for React and Redux was made (React being the most popular JS tool at that time). And the first steps toward a Magento-native PWA solution were taken.

The attention for PWA in general has been overwhelming since. If you have not caught up with this, you have been missing out hugely on what is playing in the community. Everybody feels the same way: The current frontend is too complex, PWA is the right next move. This was to be expected from the moment that Magento announced their plans with PWA Studio and GraphQL.

The current KO frontend is to be deprecated

The next question is: Will PWA Studio and the KO frontend co-exist? Well sure, they will co-exist for some time. The current KO frontend should be seen as complex, but kind of stable. It works, even though it is hard to make changes to it. But the PWA approach is hugely different: It receives data via a GraphQL API instead of Blocks (with XML layout and PHTML). It is built in JavaScript instead of a mix of JS and PHP. It requires a different workflow.

Maintaining two frontends with such huge differences is insane. Asking Magento to support both frontends – with no time limit – is asking Magento to keep outdated ugliness alive, so that no effort can be put into new upcoming technologies. That’s just stupid. PWA is the future, so it seems entirely logical to deprecate the current KO frontend at one point in the future.

Big question: When?

Anton announced the KO frontend is to be deprecated. This is entirely logical. The big question is when? It is not this year, it is not next year, it is some time in the future. Some people of the community were quick to start bashing this announcement. They asked “What about my customers? They are now migrating to Magento 2 with KO as the frontend. Is their shop dead in 2 years’ time?”

This is the same overreacting that follows every announcement of Magento 1 End-of-Life. The world is not going to end when Magento stops developing the KO frontend. And major bugs will still be fixed. It simply does not make sense to develop new features in KO. Magento 1 is also still there, but it does not mean that you should build new Magento 1 shops – it means that you can still support Magento 1 customers. While you should know better: Magento 1 is deprecated. And we have been given time to migrate.

PWA is the future, pay attention

Anyone running on deprecated software should be planning for upgrading. That’s why the term deprecated is used – it is meant to allow us transition from old to new. And I am repeating myself by saying the old frontend sucks, the new does not. PWA is the future. Pay attention to it.

Help you customers that are now migrating to Magento 2 by explaining them that Magento 2 is such a wonderful platform that things are improving constantly. The previous KO approach has proven to be less efficient for junior developers. That’s why Magento is going to focus on a more adaptable frontend. It does not mean that the old software is going to disappear, it simply means better software is underway – it’s life.

Frontend technology is changing

Another aspect to note is that Magento chose for Knockout in a time when React and Vue were not there. Back then, the choice might have been between Knockout and Angular. And I personally agree with Magento folks that the choice was for Knockout. However, that’s half a decade ago. And frontend technology is changing rapidly. The running joke is that every week a new JS library appears. And it’s true.

The big issue is that Magento can’t change that quickly: It is a giant, it needs to move slower. It needs to guarantee stability to all users. Removing something needs to be planned carefully and way in advance. Also, if you are going to make a drastic change to catch up (say: swapping one JS framework for another), it is going to have a huge impact: And because of this, we are seeing so many major changes – React, PWA Studio, GraphQL, CQRS and much more. It is a major leap to prepare for the future. In this, Magento is not leading the charge, it is following. But not following would mean fading away.

You can still stick to the old stuff

The shift to a new frontend is not a bad thing. It is just that it is one major move. And with every major move, you need to make sure you as a developer or as a business are moving along with it carefully. This does not mean that you need to be ahead of the curve. You can also watch the early adapters doing their thing and learn from their mistakes.

You can stick to the Luma theme, LESS compilation, Knockout/Require for years to come. Extensions will support it, developers will know about it. And it will be supported for quite some time – perhaps 2 years, perhaps a bit more (which is a really long time compared to the time in which frontend changes are normally taking place). And still after that, your clone of Luma will not stop working, once official support for it is dropped.

Look into your own future

However, consider this: Sometime in the future, you will need to shift from Luma to something else. Perhaps because of PWA, perhaps because of you moving away from Magento, perhaps because Magento no longer exists. Have you planned this already? Have you already decided on what this new frontend is going to be? If you are just following the crowd, simply embrace the fact that the crowd is now in full choosing PWA (with either React or Vue being the main framework). If you are not following the crowd, note that Magento is working hard on giving you flexibility instead (by using the headless approach).

One day, the KO frontend will cease to exist. One day, Magento will cease to exist. One day, the world will cease to exist. The further you look into the future, the harder it becomes to predict things. My advice is just to look ahead in the future for a couple of years time. It’s exactly in that timeframe that you will need to refactor your frontend skills. Because frontend technology changes every year. And with Magento, I’m glad that it changes now in 3 years time.

Think about what you want to deprecate

You will need to plan for this future. Things are about to change. And in the near future, frontend technology is changing rapidly – outside of the scope of Magento, but because of that, also with Magento itself. Carefully plan your strategy around this. Get ready in time.

Whenever something is changing, something old is left behind. That’s what Magento is doing: It is changing, therefore leaving something old behind. That something is the current KO frontend, that we can live without easily, as long as it is replaced with something much cooler. And PWA is much cooler. Even better, Magento has not announced this change when they are actually making it, they are announcing it way in advance, so that we have years still to prepare. So that you can prepare. Don’t complain about it, plan around it. Hopefully, this little flame is something you can share. Because I think it is making the future of Magento brighter.

Back to TOP