My question is as simple as it says in the title. Its why would Magento choose knockout instead of other frameworks like angular or react?
Is there a specific reason?
Also is this the right platform to ask this question?
My question is as simple as it says in the title. Its why would Magento choose knockout instead of other frameworks like angular or react?
Is there a specific reason?
Also is this the right platform to ask this question?
I believe it's the same reason they chose LESS over Sass - React didn't have a large stable community behind it when Magento 2 was first started, I'm not sure if Angular did but either way I've heard Angular is quite complex and would seem overkill for Magento in my opinion.
Knockout is lightweight, isn't overkill and meets the requirements Magento had at the time.
There is a React based progressive web app (PWA) version of Magento which we should be able to checkout at some point this year but there is no release date as it's in an early concept stage from what I can see. For info on that see here.
If Magento 2 was build using react your question would be "Why doesn't it use Angular or KnockoutJs?".
If it was built using Angular....you know where this is going.
I'm not an authority on this, but I speculate it was the weapon of choice because the team was more comfortable with KOjs and it suited their needs based on their roadmap.
There was a similar debate to why choose less over sass (read more about it here: https://alankent.me/2016/05/21/magento-2-community-project-moving-from-less-to-sass/)
I also heard discussions about why ZF and not Symfony. Same thing...it's a matter of choosing the right tools suited for the job, the tools you are comfortable with.
Anyway...you are not limited too much about this choice. You can choose the tech stack, specially for frontend, that suits you best.
You may need to put in some extra effort, but you will do it only once and can reuse the results in future projects.
There are already projects out there on magento with react for example.
Here is an awesome vide from Riccardo Tempesta: https://www.youtube.com/watch?v=ElZ5UtTXpzQ
Also you can find here a proxy between react and magento: https://github.com/McFizh/magento2-react
You can find even more with a simple search online.
Don't know the official reason, but having used it, Knockout seems a lot more lightweight, loads the minimal necessary and suitable for integrating with Magento2 frontend templates than the heavier Angular or React.
Also the easy way RequireJS and gulp automatically blend with knockout to reduce load time and file sizes was probably important, am guessing, but fairly certain front end speed was a major consideration when planning out Magento2.
I think a better question is, why is m2 so heavily coupled with frontend?
A lot of JS frameworks were already around when M2 released.
M2 Would have been a lot more popular if people:
Basically a lot of ET ALS. But no, they force you to use their over engineered frontend, xml driven monstrosity.
The good thing is, they have a REST API, so you can go headless and build a progressive web app.
Please, don't worry about it. As Anton Kril announced at the MageConf2017 -since 2.4 version Magento2 frontend will have React. And also, Redux of course, and GraphQL. But... Knockout.js will remain.
webapi
area), the new API is fit for that. PWA Studio is just their way of providing a base to those who need it.
Commented
Apr 1, 2018 at 8:58