User Interface20% of the exam

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.

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

~7 min read · 7 practice questions ·

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

Size limits
Detail
5 MB per static resource; 250 MB per org
Scope
Detail
Usable only within your org; can't host content for other sites
Private cache
Detail
Cached only for the current user's session, not shared
Public cache
Detail
Shared cache, faster loads; open to all internet traffic once cached
Visualforce archive entry
Detail
URLFOR($Resource.name, 'path/file')
LWC import
Detail
import X from '@salesforce/resourceUrl/name', then concatenate a path
Aura archive entry
Detail
$Resource.name + '/path/file'; no URLFOR
loadScript() and loadStyle()
Detail
Return promises; first argument must be this
ltng:require timing
Detail
Use afterScriptsLoaded, not init
Cross-model duplicates
Detail
ltng:require plus loadScript() on one URL loads it twice
Sources for this section (6)
  • 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?

The questions are free to read. Answers with their sources and self-grading are included with the pack.

Keep reading with the Platform Developer II pack

  • Core concepts
  • Exam traps
  • Worked scenario

The pack includes:

  • All 28 lessons of the Platform Developer II guide, with reading progress
  • Interactive decision walks and step-by-step sequence steppers
  • Inline practice questions and one-click topic practice (7 questions for this lesson)
  • An official source cited for every claim
  • An AI tutor that answers from the guide
  • Unlimited timed practice exams

Practice for the Platform Developer II exam