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 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. Archive static resources aren’t supported at this time.

In Summer ’23, primed images aren’t automatically 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. LWC Offline-enabled apps can provide other methods of purging stale images. Check the documentation for your target mobile app.

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.