PDI practice question 16 of 30
Which three Salesforce resources can be accessed from a Lightning web component? Choose 3 answers
Full set: 201 questionsLightning Web Components (LWC) can access several types of Salesforce-managed resources through specific, secure mechanisms. LWCs use the @salesforce/resourceUrl scoped module to import and reference static resources, which can contain JavaScript libraries, CSS, and images. Similarly, the @salesforce/contentAssetUrl module provides a URL to content asset files, making them accessible within a component. SVG images are also directly supported; they can be included in a component's HTML template, often for icons, or loaded from a static resource. These mechanisms ensure that all assets are served through the Salesforce platform, maintaining security and performance standards.
B. All external libraries: Lightning Locker Service restricts direct access to arbitrary external libraries from CDNs for security. Libraries must be uploaded as static resources to be used.
D. Third-party web components: Generic, non-Salesforce web components cannot be used directly. Components must be built as LWCs or be part of a managed package to be composed.
1. Static Resources: Salesforce Lightning Web Components Developer Guide, "Access Static Resources". This section details the use of the import { resourceUrl } from 'lightning/platformResourceLoader' and the @salesforce/resourceUrl/{resourceName} scoped module to access static resources from within a component's JavaScript.
2. Content Asset Files: Salesforce Lightning Web Components Developer Guide, "Access Content Asset Files". This page explains how to use the @salesforce/contentAssetUrl/{assetName} scoped module to get the URL for a content asset file, which can then be used in templates.
3. SVG Resources: Salesforce Lightning Web Components Developer Guide, "Use SVGs". This document describes how to use SVG icons, including referencing them from the Lightning Design System (SLDS) utility icons or from static resources. It states, "To use an SVG resource, import it and use it in the template."
4. Third-Party Libraries (Refuting B): Salesforce Lightning Web Components Developer Guide, "Use Third-Party JavaScript Libraries". This guide clarifies that external libraries must be uploaded to Salesforce as static resources and are subject to the security restrictions of Lightning Locker. It does not permit access to "all" external libraries directly.
Keep practicing
Take the free PDI practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
Other PDI practice questions
- Question 1What can be used to override the Account's standard Edit button for Lightning Experience?
- Question 4Universal Containers (UC) wants to lower its shipping cost while making the shipping proc…
- Question 5A developer has an integer variable called maxAttempts. The developer needs to ensure tha…
- Question 7Universal Containers wants to back up all of the data and attachments in its Salesforce o…
- Question 8Universal Containers hires a developer to build a custom search page to help users find t…
- Question 9As part of new feature development, a developer is asked to build a responsive applicatio…
