# UI performance: view state, LDS and lazy loading

*Platform Developer II Study Guide · Performance · Last updated October 16, 2026 · https://www.certifyforce.com/study-guide/platform-developer-ii/performance/ui-performance-view-state-lds-and-lazy-loading*

How to diagnose and fix slow Visualforce pages (view state, repeated getters, read-only mode, pagination) and slow Lightning web components (Lightning Data Service caching, fewer fields, lazy creation, listener cleanup, infinite loading and production settings).

- Certification: Salesforce Platform Developer II
- Exam section: Performance
- Study guide: https://www.certifyforce.com/study-guide/platform-developer-ii

**Official exam objective:**

> Identify the common performance issues for user interfaces and demonstrate knowledge of techniques and tools to mitigate them.

## What the exam expects

- Shrink a Visualforce view state with `transient`, read-only components, narrower queries and pagination, and stop getters from re-querying.
- Use `readOnly="true"` and `StandardSetController` when a Visualforce page must show large collections.
- Cut Lightning web component server trips with Lightning Data Service, and request fields instead of layouts.
- Defer rarely used components with tabs and `lwc:if`, remove global listeners in `disconnectedCallback()`, and page large tables with infinite loading.
- Recommend production settings for debug mode and secure browser caching.

Key terms: **view state** (the encrypted hidden field that carries component, field and controller state between Visualforce requests), **transient** (an instance variable kept out of the view state), **Lightning Data Service** (the managed client cache of records shared by components), **lazy instantiation** (creating a component only when the user needs it), **debug mode** (unminified framework JavaScript for development).

## Key facts

| Fact | Detail | Source |
|---|---|---|
| View state limit | 170 KB | [Optimize the View State](https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_best_practices_perf_view_state.htm) |
| Visualforce response limit | 15 MB | [Best Practices for Improving Visualforce Performance](https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_best_practices_perf_intro.htm) |
| `readOnly="true"` iteration limit | 1,000 raised to 10,000 items | [Setting Read-Only Mode for an Entire Page](https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_controller_readonly_context_pagelevel.htm) |
| `readOnly="true"` query rows | 50,000 raised to 1,000,000; no DML | [Setting Read-Only Mode for an Entire Page](https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_controller_readonly_context_pagelevel.htm) |
| StandardSetController maximum | 10,000 records; a larger query locator throws LimitException | [StandardSetController Class](https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/apex_pages_standardsetcontroller.htm) |
| Static variables | Never transmitted in the view state | [Using the transient Keyword](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_keywords_transient.htm) |
| `lightning-record-form` | Specify fields, not a layout, for performance | [Data Guidelines](https://developer.salesforce.com/docs/platform/lwc/guide/data-guidelines.html) |
| Datatable infinite loading | `enable-infinite-loading` plus `onloadmore` | [Datatable](https://developer.salesforce.com/docs/component-library/bundle/lightning-datatable/documentation) |

## Check yourself

- Why does `transient` fix a view state error caused by a list that a getter rebuilds every request?
- When is `readOnly="true"` the right fix for a Visualforce collection error?
- Why should a `lightning-record-form` list fields instead of `layout-type="Full"`?
- Which two production settings restore Lightning page speed after a misconfiguration?

## Sources

- [Best Practices for Improving Visualforce Performance](https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_best_practices_perf_intro.htm)
- [Optimize the View State](https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_best_practices_perf_view_state.htm)
- [Using the transient Keyword](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_keywords_transient.htm)
- [Write Efficient Getter Methods](https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_best_practices_perf_getters.htm)
- [Setting Read-Only Mode for an Entire Page](https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_controller_readonly_context_pagelevel.htm)
- [StandardSetController Class](https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/apex_pages_standardsetcontroller.htm)
- [Lightning Web Components Performance Best Practices](https://developer.salesforce.com/blogs/2020/06/lightning-web-components-performance-best-practices)
- [Data Guidelines](https://developer.salesforce.com/docs/platform/lwc/guide/data-guidelines.html)
- [Render DOM Elements Conditionally](https://developer.salesforce.com/docs/platform/lwc/guide/create-conditional.html)
- [Debug Mode](https://developer.salesforce.com/docs/platform/lwc/guide/debug-debug-mode.html)
- [Datatable](https://developer.salesforce.com/docs/component-library/bundle/lightning-datatable/documentation)
- [Improve Datatable Performance](https://developer.salesforce.com/docs/platform/lwc/guide/data-table-performance.html)
- [Run Code When a Component Renders](https://developer.salesforce.com/docs/platform/lwc/guide/create-lifecycle-hooks-rendered.html)

## About the full unit

The "Core concepts", "Exam traps" and "Worked scenario" sections of this unit, its 11 linked practice questions, and unlimited timed mock exams are included with the Platform Developer II pack (USD $19): https://www.certifyforce.com/practice-exams
