cancel
Showing results for 
Search instead for 
Did you mean: 
Subscribe

Hello,

We are using viz controls to build charts, and I observed that we are using 32 controls from the same library.

But I can't do library preload at index html or bootstrap level, because the framework that we are using is re-used across multiple application and many of those are not using viz library.

So, I tried loading the library-preload.js in the controller where the chart are used. Below is the code snippet of the same.

Please suggest is it fine to use this way.

sap.ui.define([ "sap/ui/core/mvc/Controller", "sap/m/IconTabFilter", "sap/ui/model/json/JSONModel", "sap/viz/library-preload" ], function(Controller,
IconTabFilter, JSONModel, vizLib) {


});

This is avoiding 30+ requests as all required controls are loaded in a single file.

View Entire Topic
maheshpalavalli
Active Contributor

Hi Pradeep T N,

You don't need to load preload file explicitly. UI5 framework automatically sends a request and loads it for us. So just use the normal namespace, which should be enough.

Your code looks fine and it will load the requests once that particular view is loaded. If you want to load the libraries manually when you need, then use this.

https://ui5.sap.com/#/api/sap.ui/methods/sap.ui.require

Else you can also use the library at the manifest.json but pass the lazy as true. So only when the viz frame is required, it will be loaded.

https://ui5.sap.com/#/topic/8521ad1955f340f9a6207d615c88d7fd

Thanks,

Mahesh

0 Likes

Hello maheshkumar.palavalli

I didn't understand part of your answer "You don't need to load preload file explicitly. UI5 framework automatically sends a request and loads it for us. So just use the normal namespace, which should be enough".

What do you mean by using namespace? Can you please share a sample code snippet.

Thanks
Pradeep

maheshpalavalli
Active Contributor
0 Likes

Hi Pradeep T N,

See the below example, they just used "sap.viz":{}

https://ui5.sap.com/#/entity/sap.viz.ui5.controls.VizFrame/sample/sap.viz.sample.Area/code/manifest....

You can pass lazy as true and it will not load it immediately, it will load it whenever the app requests for the ui5 resources. Check my original answer links for more info.

Now the above code will send a request to load the preload file of sap.viz automatically, you don't need to to explicitly mention that and I doubt it works if you mention it like that.

Thanks,

Mahesh