Newer Version Available

This content describes an older version of this product. View Latest

Image Priming and Offline Considerations

LWC Offline isn’t magic. If an image hasn’t been primed before you go offline, it can’t be displayed while offline. LWC Offline primes image assets that are referenced in component template files, in the src attribute of a standard HTML img tag.

Only the img tag is supported at this time. Images referenced in other ways or tags aren’t primed and won’t display sometimes, even when online.

Note

Primed images are stored locally on the mobile device, in a new binary durable store (cache). Images stored in individual files are primed and cached individually. Images stored in archive asset files are accessible, but be aware that the entire archive is primed and cached. Updates to images in archive files require reloading the entire archive.

In Spring ’23, primed images aren’t purged from the offline cache when they get stale. Be mindful of the size of your images or archive asset files, and the space they take up locally on devices.

The binary contents of an item referenced in an img tag isn’t validated. It’s up to you to ensure that referenced files are valid images. Support for specific image formats is dependent on the capabilities of the web view, which is provided by the operating system. Providing an unsupported or non-image file to an img tag is an HTML error and can cause unpredictable behavior. As the joke goes, don’t do that. Safe formats are the usual web image formats: GIF, JPEG, PNG, and so on. When in doubt, test specific image formats on your specific supported mobile devices and operating system versions.