cancel
Showing results for 
Search instead for 
Did you mean: 

When should I use uiComponent vs Layout/block/template method?

When should I use uiComponent vs Layout/block/template method?

From what I've seen, there's a lot more Javascript used in uiComponents. This seems to be a departure from when everything was done with PHP.

My question is: How do you decide which one to use? Is uiComponent just the way that we do things now?

3 REPLIES 3

Re: When should I use uiComponent vs Layout/block/template method?

Hi @media_bloke 

 

It's up to you what to use in development UI component has it's own benefits.Yes it has alot of javascript but it make your content more secure in front end. Here are some benefits of using UI components:

 

  • Simplified layout.xml for the backend part of Magento 2
  • Ability to merge HTML and JavaScript items and use this compound element as a JavaScript code
  • Ability to create sophisticated UI components using basic ones
  • Ability to use a single entity for rendering a UI element and working with it.  

So in terms of using traditional layout/block it makes process bit longer and harder so in my opinion UI Components are good to use.

 

Hope this helps you.

 

if above answer was helpful then please Accept as Solution & give Kudos
Shubham Khandelwal    

Re: When should I use uiComponent vs Layout/block/template method?

Thanks. I'm more confident with JS than xml/php, so I was happy to see uiComponents as an option, but don't we want more things rendering on the server instead of the clients machine? 

Won't the site run faster that way?

Re: When should I use uiComponent vs Layout/block/template method?

Hi @media_bloke 

 

Yes indeed it will cause if we are doing things using js at the end we know it merges and site get run faster.

 

All The Best.

 

Hope this helps.

 

if above answer was helpful then please Accept as Solution & give Kudos
Shubham Khandelwal