# When to load data

### Sync data when the solution loads or gets focus

**Benefits:**

* The app is robust for offline scenarios.
* Jig rendering and interaction are very fast.
* There are only 2 distinct cloud interaction cycles in the example below: once when all data is synced and once when an update is sent to the cloud.

This is the recommended pattern when designing a Jigx solution.

**Drawbacks:**

* Initial app load time is slightly longer and heavier.
* Doesn’t work for all scenarios where the app depends on up-to-date data from the cloud when a jig is displayed.

<figure><img src="/files/pgvB7DHG7TAa6fP3Z9sd" alt="Solution data sync"><figcaption><p>Solution data sync</p></figcaption></figure>

### Sync just in time when a jig is used

**Benefits:**

* Initial load is lighter.
* Only the data needed per screen is synced to the device.

Elements of this approach can be combined with the recommended approach above.

**Drawbacks:**

* The solution cannot robustly go offline.
* The data might not be available for the jig when the app is offline.
* The user might experience a slower performance of jigs because of just-in-time cloud operations.
* There are 9 (8 reads and one update) cloud operations throughout the UI cycles at 5 different distinct stages.

<figure><img src="/files/eML3bWic2Dh4wROutmsL" alt="Sync data just in time"><figcaption><p>Sync data just in time</p></figcaption></figure>

### Dynamically syncing data

When building a solution, the number of entities to sync and the parameters for each are not always known; for example, when syncing the attachments for a message, there can be zero, one or more attachments, or files/documents stored in a OneDrive directory. It is necessary to dynamically specify a list of the entities and function+parameters to return from the database using an expression. See [Dynamically sync multiple entities](https://docs.jigx.com/examples/readme/actions/sync-entities#dynamically-sync-multiple-entities) for more information.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.jigx.com/building-apps-with-jigx/data/when-to-load-data.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
