Pergunta

We are working on a mobile portal using Worklight 5.0.6 with the Mobile Web environment.

While loading the application, all the resources like js, css, images etc.. are loaded together. Due to this it takes too much time to load the page. How can we restrict the resources (which are not required) to be loaded together with the application. And how can we force to load only the required resources?

Foi útil?

Solução

Sounds like what you're asking is:

  1. How to reduce the size of the application
  2. How to reduce the network traffic produced by the application

Indeed, in Worklight 6.0.0.0 there is: the Minification and Concatenation feature as well as application cache (auto-manifest generation). Since you don't have that in 5.0.6, what you could do is:

  1. Regardless of any feature, only keep in your app what you're actually using.

    • Remove images and libraries you're not using
    • Use png-crush to minimize the file size of images
    • Remove dead code

  2. For network traffic:

    • Add a manifest file to your application and list in it all the resources you'd like to cache as opposed to always fetch. Application Cache is a web standard so you can simply follow articles on the web.

    • You could "manually" minify your application resources; you can accomplish this using Google Closure.

    • BE CAREFUL! If you choose this path, make sure to only use the WHITESPACE_ONLY or SIMPLE_OPTIMIZATION compilation levels. Do not use ADVANCED_OPTIMIZATIONS on the Worklight framework files - behavior will be unknown (it may work, it may not, it could suddenly fail at some parts - this is not supported by Worklight).

  3. As for only loading what you want to, ala RequireJS, Worklight is not yet equipped to handle this, so this is not a viable option for you.

There is IMO not much to do in 5.0.6 about this; 6.0.0.0 took it a step forward and the upcoming 6.1.0 handles it better as well (the Mobile Web environment is much lighter in regards to its structure and number of files), but you cannot do moduler loading of resources just yet.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top