# Static resources in Visualforce, LWC and Aura

*Platform Developer II Study Guide · User Interface · Last updated October 16, 2026 · https://www.certifyforce.com/study-guide/platform-developer-ii/user-interface/static-resources-in-visualforce-lwc-and-aura*

Why files belong in static resources (name-based references, zip hierarchies, the content security policy, caching) and the exact reference syntax in each technology: $Resource and URLFOR in Visualforce, @salesforce/resourceUrl and platformResourceLoader in LWC, $Resource concatenation and ltng:require in Aura.

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

**Official exam objective:**

> Describe the purpose and benefit of static resources in Visualforce, Lightning Web Components, and Aura Components.

## What the exam expects

- Explain why static resources beat the Documents tab, inline scripts and hardcoded IDs, and what they can't do (host content outside the org).
- Reference a standalone file and a file inside a zip archive in Visualforce, a Lightning web component and an Aura component.
- Load a third-party JavaScript library from a static resource with `loadScript()`/`loadStyle()` in LWC and `ltng:require` in Aura, at the right point in the lifecycle.
- Apply the size limits and choose Private or Public cache control.

Key terms: **static resource** (an uploaded file or archive referenced by name), **archive static resource** (a .zip or .jar whose internal folders are addressed by path), **`$Resource`** (the Visualforce global variable and the Aura global value provider for static resources), **`@salesforce/resourceUrl`** (the LWC scoped module that imports a resource URL), **cache control** (Private per session or Public shared cache).

## Key facts

| Fact | Detail | Source |
|---|---|---|
| Size limits | 5 MB per static resource; 250 MB per org | [Using Static Resources](https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_resources.htm) |
| Scope | Usable only within your org; can't host content for other sites | [Using Static Resources](https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_resources.htm) |
| Private cache | Cached only for the current user's session, not shared | [Access Static Resources](https://developer.salesforce.com/docs/platform/lwc/guide/create-resources.html) |
| Public cache | Shared cache, faster loads; open to all internet traffic once cached | [Access Static Resources](https://developer.salesforce.com/docs/platform/lwc/guide/create-resources.html) |
| Visualforce archive entry | `URLFOR($Resource.name, 'path/file')` | [Referencing a Static Resource in Visualforce Markup](https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_resources_reference.htm) |
| LWC import | `import X from '@salesforce/resourceUrl/name'`, then concatenate a path | [Access Static Resources](https://developer.salesforce.com/docs/platform/lwc/guide/create-resources.html) |
| Aura archive entry | `$Resource.name + '/path/file'`; no URLFOR | [$Resource](https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/expr_resource_value_provider.htm) |
| `loadScript()` and `loadStyle()` | Return promises; first argument must be `this` | [Platform Resource Loader](https://developer.salesforce.com/docs/platform/lightning-component-reference/guide/lightning-platform-resource-loader.html?type=Develop) |
| `ltng:require` timing | Use `afterScriptsLoaded`, not `init` | [Using External JavaScript Libraries](https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/js_libs_platform.htm) |
| Cross-model duplicates | `ltng:require` plus `loadScript()` on one URL loads it twice | [Platform Resource Loader](https://developer.salesforce.com/docs/platform/lightning-component-reference/guide/lightning-platform-resource-loader.html?type=Develop) |

## Check yourself

- Why is a zip static resource better than files on the Documents tab for Visualforce pages deployed to several orgs?
- When should an Aura component call a library loaded by `ltng:require`?
- Why does a Lightning web component load a charting library in `renderedCallback()` instead of `connectedCallback()`?
- What are the size limits for static resources?

## Sources

- [Using Static Resources](https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_resources.htm)
- [Referencing a Static Resource in Visualforce Markup](https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_resources_reference.htm)
- [Creating a Static Resource](https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_resources_create.htm)
- [Access Static Resources](https://developer.salesforce.com/docs/platform/lwc/guide/create-resources.html)
- [Use Third-Party JavaScript Libraries](https://developer.salesforce.com/docs/platform/lwc/guide/js-third-party-library.html)
- [Platform Resource Loader](https://developer.salesforce.com/docs/platform/lightning-component-reference/guide/lightning-platform-resource-loader.html?type=Develop)
- [$Resource](https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/expr_resource_value_provider.htm)
- [Using External JavaScript Libraries](https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/js_libs_platform.htm)

## About the full unit

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