sources.json
To improve application launch times, use sources.json
to load your JavaScript files on demand instead of loading them all when the application launches.
The palm-generate
tool creates sources.json
for you with the default stage and scene files. As you build your application, add the file paths for each assistant (application, stage, and scene) to sources.json
. Do not include any files that are not actually used (for example, the optional app-assistant file). However, if the application includes app-assistant.js
, it should always be the first one listed. The scene-assistants must include both the JavaScript and scene names; HTML templates do not need to be included.
The specified format for sources.json
is as follows:
-
source--This is the location of the JavaScript file relative to
index.html
. The framework can load a JavaScript file by having its name insources.json
orindex.html
, or explicitly by the application. If a JavaScript file is not in one of these three locations, it never loads. -
scene--When you list a scene in
sources.json
, it tells the framework to load the source file when and only when the scene is pushed on the stage. If there are no scenes listed, the source file loads when the application first loads.
Example
[ { "source": "app/assistants/app-assistant.js" }, { "source": "app/assistants/stage-assistant.js" }, { "source": "app/assistants/first-assistant.js", "scenes": "first" } { "source": "app/assistants/second-assistant.js", "scenes": "second" } ]