Skip to Content
0

Load all controller files

Nov 29, 2016 at 12:53 PM

71

avatar image
Former Member

Hey,

i want to make my App offline capable. How can I load all controller files at the beginning of my App? Currently the controller files only get loaded when they are needed.

Thanks for your help and best regards,

David

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Akhilesh Upadhyay Nov 29, 2016 at 01:22 PM
0

using <script> tag you can load all javascripts files inside <head> tag in index.html.

Regards,

Akhilesh

Show 2 Share
10 |10000 characters needed characters left characters exceeded
Former Member

How can I reach the same effect without having a index.html?

0

you must have one html file in your app, you can use that file.

OR

you can use jQuery.sap.require, check below link, or you can use component-preload as Jamie suggested.

Modularization and Dependency Management

Thanks,

Akhilesh

0
Jamie Cawley
Nov 29, 2016 at 01:56 PM
0

Create a component-preload.js file with all of the app contents contained within it.

https://help.hana.ondemand.com/webide/frameset.htm?dfb26ef028624cf486a8bbb0bfd459ff.html

Regards,

Jamie

SAP - Technology RIG

Show 2 Share
10 |10000 characters needed characters left characters exceeded

I'd also say this is the best approach to answer the question: you app should be a component based app that loads the Component-preload.js file. I don't know how your dev setup looks like, but it's quite easy to generate the Component-preload.js file using grunt. Have a look at grunt-openui5 and also at the Optimizing UI5 Apps blog by Matthias Osswald. The blog Deploying UI5: Putting all the tasks together by Nigel James is another good read.

Using this approach even makes sure you have your views loaded as well. However, keep in mind that some resources like image files etc. will not be available for offline use this way. So for those other resources (which will not be part of the generated Component-preload.js file) you should implement a "pre-fetching" strategy if this is really needed (maybe inside the Component.js file).

0

Or you can use Gulp as task runner: Distribution package for an UI5 application

0