Images on PWA load slowly

Greetings fellow Ionic developers!

I built a Progressive Web App using the service worker, and my app uses images from the assets folder. However, when I try to use my PWA, I see that it takes a while for the images to load. I included my assets folder in the pre-cache :

service worker.js

self.toolbox.precache(
 [
'./build/main.js',
'./build/vendor.js',
'./build/main.css',
'./build/polyfills.js',
'index.html',
'manifest.json',
'./assets'
]
);

Anyone know how to make these images load faster (preferable immediately like how it is on the emulator/device)

Not sure but don’t you also need to include the images aswell???

Ohh but my images are in the assets folder! So shouldn’t that be enough? I’ve included the assets folder in the precache

I’d just try it, add a couple and see what happens.

Also try ./assets/*/* or something like that - but try with individual ones first, prove the concept.

The assets folder is of course enough for actual native apps, but doubt that to be the case for this :slight_smile:

Yes! I’ll give it a go!

Only problem is, all my images have the src =“assets/…” so if in the end individual images need to be added to the pre cache id have to change all those src attributes. And I have around 80 images!!!

Like I said there’s probably an option to wildcard em in.

If not, stop being lazy and get typing :wink:

(or build a crazily insanely simple script that does the job for you if they change much)

TBH Fundamentally I can’t see how a wildcard can work without the web server actively allowing a directory scan.

1 Like

Ahahaha thank you! Will definitely give it a go and see what happens. Will update the results on this thread then :slight_smile: