cancel
Showing results for 
Search instead for 
Did you mean: 

are XMLViews preferred over JSViews because of performance?

Former Member
0 Kudos

Hi,

Given an option to go with JSViews and XMLViews, which one is preferred? Does XMLView has a better performance compared to JSView in terms of time taken to instantiate a new view and render it on the screen? If yes, is the performance gain significant enough to migrate existing JSViews to XMLViews?

I have found this thread , which says that JSViews are faster than XMLViews as they do not come with a parsing overhead, but the instructors giving the training for sapui5 are against this opinion. 

1. If I have to use sap.ui.core.HTML control, how and where do i call setContent and attachAfterRendering methods in XMLView? Typically, in JSViews, we create the HTML control and call setContent and attachAfterRendering methods in subsequent lines.

2. Can XMLViews be extended like JSViews?

Thanks

Ashwani Chandra

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

No, it's not preferred just because of the performance. Using XML views you get a cleaner code, say if you wanna create a button just doing this would be enough,


<Button text="XML View" />

But the same thing in js would be,


var oButton = sap.m.Button({text:"JS View"});

So, in xml views we can avoid the namespace that has to be written for every control by declaring the namespace to xmlns, which can't be done in javascript. Obviously JS views must be faster than XML Views as they don't need to be parsed but the time to parse XML is very fast, so there wont be any significant difference when the performance is considered. One more reason to prefer XML views could be, it's declarative. Common practice to develop a web page is using HTML which is also declarative.

Regards

Sakthivel